Views are mirrored in RTL languages

戏子无情 提交于 2019-12-12 07:47:16

问题


When setting your device to a Right-To-Left language, iOS reverses the order of items.

For example in a UITableViewCell set with Auto-Layout: I have an avatar image on the left and some text aligned right from it that fills up the rest of the cell. In Arabic my avatar is on the right and my label is on the left.

Is there a way to prevent iOS from doing this on certain views, or is there a general setting defining whether or not it can be reversed?


回答1:


For Xcode6 and iOS8 you can uncheck Respect language direction for the horizontal constrains like below:




回答2:


You can set the 'direction' property of a spacing layout to "Left to Right" instead of the default: "Leading to trailing". This way the views will not be mirrored in RTL languages.

Unfortunately, you have to set this for every constraint of the views you don't want mirrored. Constraints added with code can be set this way: [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[_photoView]-0-|" options:NSLayoutFormatDirectionLeftToRight metrics:nil views:views]];



来源:https://stackoverflow.com/questions/20679716/views-are-mirrored-in-rtl-languages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!