What if you’re developing an App that is only in Arabic, or Hebrew, or any other RTL language. And you don’t really want to develop it in English first, then localise the strings. Usually you’d have this problem for example:
This has 3 layout problems:
- The navigation back button is on the left.
- The TableView section title is on the left.
- The Main text label of the UITableViewCell is also on the left.
Well luckily, since iOS 9, Apple provided a way to control this programmatically quite simply. Just use the UIView and UINavigationBar properties semanticContentAttribute. So for example if I add the following 2 lines to my AppDelegate application didFinishLaunchingWithOptions:
UIView.appearance().semanticContentAttribute = .forceRightToLeft
UINavigationBar.appearance().semanticContentAttribute = .forceRightToLeft
And voila:
This way you can just develop using a single storyboard and not worry about localisation if you don’t need it.
You can check out the documentation for semanticContentAttribute at https://developer.apple.com/documentation/uikit/uiview/1622461-semanticcontentattribute