Swift 更改日期选择器语言 [英] Swift change date picker language
本文介绍了Swift 更改日期选择器语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改 UIDatePicker 中月份表示的格式.我试过了:
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.
推荐答案
您应该将 loc
分配给日期选择器 locale 属性:
You should assign loc
to the date picker locale property:
let loc = Locale(identifier: "uk")
self.datePicker.locale = loc
这篇关于Swift 更改日期选择器语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文