Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing to right to left RTL programmatically

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.

like image 346
SalmaGh Avatar asked Feb 02 '16 10:02

SalmaGh


1 Answers

in Swift 4 try this,

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

//FOR LEFT TO RIGHT
 UIView.appearance().semanticContentAttribute = .forceLeftToRight
like image 193
Jaydip Avatar answered Oct 17 '22 21:10

Jaydip