RTL layouts
bluemix opened this issue · 5 comments
bluemix commented
radianttap commented
Leading, trailing constraints should do this automatically. Will see what's going on
radianttap commented
This seems out of reach, for now.
Main.storyboard
seems to be loaded and rendered using Locale.preferredLanguages.first
before any swizzling can take place. I even tried to swizzle that, but no use.
FadyAckad commented
I found a workaround by unloading the main bundle.
Bundle.main.unload()
Not sure if it has any performance drawbacks, but it's working fine for me till now.
radianttap commented
Thanks, I'll have to try that
mushthak commented
@FadyAckad
Were did you called this method?
Below update did the fix for me:
static func updateLanguage(code: String, regionCode: String? = nil) {
if(code == "ar"){
UIView.appearance().semanticContentAttribute = .forceRightToLeft
}else{
UIView.appearance().semanticContentAttribute = .forceLeftToRight
}
enforceLanguage(code: code, regionCode: regionCode)
// post notification so the app views can update themselves
NotificationCenter.default.post(name: NSLocale.currentLocaleDidChangeNotification, object: Locale.current)
}