Search code examples
swiftuidatepicker

Why are the days in the .inline style UIDatePicker not being localised when applying a locale to the datpicker?


I am setting the locale of a UIDatePicker outlet to be Arabic and the preferred style to be inline as follows:

picker.locale = Locale(identifier: "ar_AE")
picker.preferredDatePickerStyle = .inline

The localisation is being applied to the month and year drop-down selection but not to the days of the calendar as shown in the screenshot below:

Screenshot 1

Screenshot 2


Solution

  • Set your locale to the picker.calendar.locale also, then you can get the weekdays in your desired locale

    picker.locale = Locale(identifier: "ar_AE")
    picker.calendar.locale = Locale(identifier: "ar_AE")
    picker.preferredDatePickerStyle = .inline
    

    enter image description here