To change LTR to RTL I am using one storyboard with autolayout constraints leading and trailing. On the button click of change language to Arabic/English. I am calling switchLanguage(). Which changes the LTR to RTL and vice versa. All layout seems to be good.
The issue is after changing semanticContentAttribute from .forceLeftToRight to .forceRightToLeft or vice versa multiple times. The app navigations seems to be very slow and I have noticed the CPU usage reaches to 99%. The more you switch language the more is slower.
func swichLanguage {
if Lang.current = .ar {
UIView.appearance().semanticContentAttribute = .forceRightToLeft
} else {
UIView.appearance().semanticContentAttribute = .forceLeftToRight
}
let sb = UIStoryboard.init(name: "Main", bundle: nil)
let vc = sb.instantiateInitialViewController()
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window?.rootViewController = vc
}