Disable Autolayout Localization Behavior (Rtl - Right to Left Behavior )

Disable Autolayout Localization Behavior (RTL - Right To Left Behavior )

To make leading act always as left (and trailing always like right), i.e. make it language independent, you can remove checkmark on "Respect language direction" on all constrains.

You can find this checkmark in constrain settings in the Attributes inspector under "First Item" button.

Respect language direction

Objective c Disable Autolayout Localization Behavior for Arabic

You can force your UIView's direction by using UISemanticContentAttribute

i.e, to force Right to left direction, apply

[myView setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];

On your view.

Cancel automatic RTL flip with autolayout when doing localization

I'm afraid I'll have to answer your question with another question... why would you not want that?

Right-to-left languages are expected to have right-to-left UI. The notions of forward and backward, leading and trailing are generally flipped when it comes to Right-to-left languages.

I would highly recommend you keep your UI flipped for these languages because this is what users expect; it's the best experience you can provide for Arabic, Hebrew, and other RTL languages.

In any case, if you do run into a case where the directionality must remain the same for any language: I'm assuming you're using Auto Layout/constraints since you're mentioning xibs and automatic flipping — all you have to do is change the constraint types from Leading to Left and Trailing to Right. 'Left' and 'Right' are still the same in RTL, as opposed to Leading and Trailing.

Auto RTL, LTR constraints behavior

As long as you only support English as a localization in your project, there should be no work needed to guarantee that your app will always be LTR, even with leading/trailing constraints.

Screenshot of an Xcode project highlighting the "Localizations" section of the Project inspector, showing English as the only supported language, even with Base internationalization turned on.

Views are mirrored in RTL languages

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



Related Topics



Leave a reply



Submit