Ios – Changing to right to left RTL programmatically

iosiphoneright-to-leftswift

I'm working on an App which supports two languages: English and Arabic.
When the user changes the language to Arabic, I need my app to make the text right-to-left (RTL).

I searched for this issue, and I found this answer about supporting RTL.

I would like to do apply the the above answer but in a programmatically way, because I need to change from LTR to RTL while the App is running.

Best Answer

in Swift 4 try this,

//FOR RIGHT TO LEFT
 UIView.appearance().semanticContentAttribute = .forceRightToLeft

//FOR LEFT TO RIGHT
 UIView.appearance().semanticContentAttribute = .forceLeftToRight
Related Topic