0

So, I tried changing the app language programmatically from English to an RTL language. The text is localized but the layout is still LTR until I restart the app that RTL takes effect.

Is there a way to make this happen without restarting the app?

Greg
  • 18,111
  • 5
  • 46
  • 68
Zakaria
  • 1,040
  • 3
  • 13
  • 28

1 Answers1

0

I ended up forcing RTL in runtime using the setSemanticContentAttribute method like bellow:

if ([NSLocale characterDirectionForLanguage:languageCode] == NSLocaleLanguageDirectionRightToLeft) {
    if ([[[UIView alloc] init] respondsToSelector:@selector(setSemanticContentAttribute:)]) {
        [[UIView appearance] setSemanticContentAttribute:
         UISemanticContentAttributeForceRightToLeft];
    }
}
else {
    if ([[[UIView alloc] init] respondsToSelector:@selector(setSemanticContentAttribute:)]) {
        [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
    }
}
Zakaria
  • 1,040
  • 3
  • 13
  • 28