I'm finally getting round to wrestling with Auto Layout and can't seem to figure out how to get right-to-left (RTL) support to work the way I'd expect/want...
I have designed the view in Interface Builder as shown:
With the resulting app running as expected when using English:
However when switching to an RTL language (Arabic in this case), the entire view flips (which is great) but the UILabel
's text is still left aligned. I'd expect it to be right aligned to keep it up against the UIImageView
.
Clearly I'm missing something and/or this isn't covered by Auto Layout.
Am I supposed to set the textAlignment
manually when using an RTL language?
You want NSTextAlignmentNatural
. That infers the text alignment from the loaded application language (not from the script).
For iOS 9 and later (using Xcode 7), you can set this in the storyboard (choose the --- alignment option). If you need to target earlier releases, you'll need to create an outlet to the label and set the alignment in awakeFromNib
.
- (void)awakeFromNib { [[self label] setTextAlignment:NSTextAlignmentNatural]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With