Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Views are mirrored in RTL languages

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?

like image 250
Jovan Avatar asked Dec 19 '13 10:12

Jovan


People also ask

What is RTL language support?

Some languages of the world (Arabic, Hebrew etc.) are RTL, meaning they are read right-to-left, instead of left-to-right. Typically in web applications supporting one of these languages, everything is reversed, meaning scroll bars, progress indicators, buttons etc.

What is RTL layout?

An RTL layout is the mirror image of an LTR layout, and it affects layout, text, and graphics. It is also called as 101 rules for Bi-directional UX. When a UI is changed from LTR to RTL (or vice-versa), it's often called mirroring, but it's not just mirroring.

What is ltr and RTL?

For example, the en-US locale (for US English) specifies left-to-right. Most Western languages, as well as many others around the world, are written LTR. The opposite of LTR, RTL (Right To Left) is used in other common languages, including Arabic ( ar ) and Hebrew ( he ).


1 Answers

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]];

like image 60
Jovan Avatar answered Sep 25 '22 00:09

Jovan