我本质上是一个提词器应用程序,我需要一个UITextView来显示从右到左的每一行。
NSString *textString = @"Hello There\nMy name is Mark";
textView.text = [@"\u202B" stringByAppendingString: textString];这不管用。我需要这个来读
“erehT olleH”“kraM si eman yM”
我知道我也需要颠倒的字体等等。我得先把这个零件修好。谢谢。
发布于 2012-10-06 12:50:11
符号\u202b表示Unicode字符U+202B是从右到左的嵌入,这不会影响具有强方向性的字符的书写方向,例如拉丁字母。
字符从右到左覆盖( character U+202E RIGHT-TO-LEFT OVERRIDE,\u202e)强制从右向左书写方向,从而覆盖字符的固有方向性。若要结束其效果,请使用U+202C POP方向格式字符:
'\u202eHello There\nMy name is Mark \u202c'这与字体没有多大关系。渲染引擎应该处理一些字符,如使用镜像符号的“(”,例如,使得“(Foo)”在从右向左书写时被渲染为“(Oof)”而不是“)oof()”。但通常不涉及镜像;字母保持不变,它们只是从右向左排列。
如果你真的想要镜像文本,你需要一些完全不同的东西(转换)。
发布于 2012-10-06 12:06:32
这是反转字符串的逻辑...我希望这能帮到你。只需将此字符串附加到您的textView.text中
NSString *sampleString = @"Hello this is sample \n Hello there";
NSMutableString *reverseString = [NSMutableString string];
NSInteger index = [sampleString length];
while (index > 0)
{
index--;
NSRange subStrRange = NSMakeRange(index, 1);
[reverseString appendString:[sampleString substringWithRange:subStrRange]];
}
NSLog(@"%@", reverseString);https://stackoverflow.com/questions/12756539
复制相似问题