Text Alignment

The last issue is the Car Info label’s text alignment. Although the text is shown right-to-left, the label itself uses left alignment. Things such as the Car Number label work because the label is just as big as it needs to be to show the text.

The car info area is larger than it needs to be and is left aligned, the default for all labels. Although the text direction is reversed, it still is aligned to the left, and the label is larger than just the size of the text.

There is no automatic way to correct for this. Auto layout has already updated the leading and trailing alignment of the label. You need to detect a right-to-left language and change the alignment of the car info view.

Add the code from Listing 5-6 to the viewWillAppear: ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.