UILabel和从右到左的文字

时间:2022-06-25 09:25:39

I have a collection of NSString objects that contain arabic text. However, when I try to display any of them using a UILabel, the text shows left-to-right instead of right-to-left (NSLog shows the strings properly)

我有一个包含阿拉伯文本的NSString对象的集合。但是,当我尝试使用UILabel显示其中任何一个时,文本从左到右而不是从右到左显示(NSLog正确显示字符串)

I am thinking about a work-around, applying a transform to the UILabel to make a y-axis symmetry, but how can I detect if a NSString contains a RTL string?

我正在考虑解决方法,将变换应用于UILabel以使y轴对称,但是如何检测NSString是否包含RTL字符串?

2 个解决方案

#1


Try prepending the unicode character 0x200F to the beginning of each string. This character is an invisible marker character that indicates text directionality.

尝试将unicode字符0x200F添加到每个字符串的开头。此字符是一个不可见的标记字符,表示文本的方向性。

#2


Have you tried setting your region to Arabic? I would have thought this type of thing would be handled automatically.

您是否尝试过将您的地区设为阿拉伯语?我原以为这种类型的东西会自动处理。

#1


Try prepending the unicode character 0x200F to the beginning of each string. This character is an invisible marker character that indicates text directionality.

尝试将unicode字符0x200F添加到每个字符串的开头。此字符是一个不可见的标记字符,表示文本的方向性。

#2


Have you tried setting your region to Arabic? I would have thought this type of thing would be handled automatically.

您是否尝试过将您的地区设为阿拉伯语?我原以为这种类型的东西会自动处理。