My Application must support Arabic(right to left direction) and English(left to right direction) language, I need to set UI and based on user select language from my applica
Use this line of code it will do your magic and will change layout without closing application. From right to left
UIView.appearance().semanticContentAttribute = .forceRightToLeft
And for Right to Left Flip
UIView.appearance().semanticContentAttribute = .forceLeftToRight
and if you want to change textfield layout or text change then use this code because i faced this issue . textfield's texts was not changning layout. check this code to change layout of textfield text.
extension UITextField {
open override func awakeFromNib() {
super.awakeFromNib()
if UserDefaults.languageCode == "ar" {
if textAlignment == .natural {
self.textAlignment = .right
}
}
}
}