My app supports right to left direction but i want to discard the phone language and just change direction depending on the user preference.
On a right to left phone, I forced the left to right using
UIView.appearance().semanticContentAttribute = .forceLeftToRight
it fixed most things but not everything.
Check the text fields placeholder alignment; some labels were aligned right! Anyone has a solution how to fix this?
try this one it will change direction of your textfield's text from left to right
extension UITextField {
open override func awakeFromNib() {
super.awakeFromNib()
if UserDefaults.languageCode == "ar" {
if textAlignment == .natural {
self.textAlignment = .right
}
}
}
}