0

I'm working with an application that has English and Arabic localizations. I need a Textfield to be in left to right text alignment in Arabic as well as English. But I'm not able to force the semantic from left to right. I've written the following code in viewDidLoad.

self.textField.textAlignment = .left
self.textField.semanticContentAttribute = UISemanticContentAttribute.forceLeftToRight

I've also tried putting the textField in a UIView and forcing the views semantic to the left to right. But still is not doesn't work.

self.textAreaView.semanticContentAttribute = .forceLeftToRight

Let me know if somebody has forced the text field from left to right in the case of RTL language. Any links are also appreciated.

EDIT: Unfortunately, I'm not able to find any solutions for this and had to change the app Flow. Still, if somebody is able to find any solution it will be very Helpful.

Arun K
  • 810
  • 2
  • 12
  • 33
  • 1
    How do you add constraints for the textField? Normally if you add leading / trailing it depends on language while right / left forces it to what you wish for. – Vollan Feb 17 '22 at 06:52
  • I've added left and right constraints to superview as textfield has borders and it is in the centre. – Arun K Feb 17 '22 at 06:55
  • Use .natural which will do this automatically – Ptit Xav Feb 17 '22 at 08:00
  • Does this answer your question? [UItextView arabic text aligned to right](https://stackoverflow.com/questions/9869923/uitextview-arabic-text-aligned-to-right) – LoVo Feb 17 '22 at 08:22

0 Answers0