Swift change date picker language

こ雲淡風輕ζ 提交于 2019-12-24 00:37:54

问题


I want to change format of month represent in my UIDatePicker. I tried:

self.datePicker = UIDatePicker()
self.datePicker.backgroundColor = .white
self.datePicker.datePickerMode = .date
let loc = Locale.init(identifier: "uk")
var calendar = Calendar.current
calendar.locale = loc
self.datePicker.calendar = calendar

After that, month representation suppose to be in ukranian, but it still in other language.


回答1:


You should assign loc to the date picker locale property:

let loc = Locale(identifier: "uk")
self.datePicker.locale = loc


来源:https://stackoverflow.com/questions/47056329/swift-change-date-picker-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!