0

I have a UIDatePicker, that shows date and time UIDatePickerMode.dateAndTime, when I present the picker while the language is Arabic, the picker is normally presented with hours on the left and minutes on the right with no issues as the below photo:

enter image description here

But if I change the language from English to Arabic, the picker switches the hours with the minutes as below:

enter image description here

I set the locale based on user selected language as:

if CURRENT_LANGUAGE_IS_ARABIC == true{
 pickerDate.locale = NSLocale.init(localeIdentifier: "ar") as Locale

}else{
 pickerDate.locale = NSLocale.init(localeIdentifier: "en") as Locale
}

EDIT: Also when changing from Arabic to English the picker is showing the hours on the wrong place:

enter image description here

Mutawe
  • 6,464
  • 3
  • 47
  • 90

1 Answers1

0

make sure that you add semanticContentAttribute

  pickerDate.locale = NSLocale.init(localeIdentifier: "ar") as Locale
  self.pickerDate.semanticContentAttribute = .forceRightToLeft
Abdelahad Darwish
  • 5,969
  • 1
  • 17
  • 35