简体   繁体   English

如何在 Swift 中更改 UIDatePicker 的颜色?

[英]How do I change the color a UIDatePicker in Swift?

How would I go about changing the color of the text in a UIDatePicker?我将如何更改 UIDatePicker 中文本的颜色? I would prefer not to use UIPickerView as I don't want to deal with the implementation of the date/time aspect of it, however, if there exists a prewritten implementation of the equivalent of a UIDatePicker as a UIPickerView, I would be open to it.我宁愿不使用 UIPickerView,因为我不想处理它的日期/时间方面的实现,但是,如果存在 UIDatePicker 等价物的预写实现作为 UIPickerView,我会开放它。

Note, I am using Swift 5.请注意,我使用的是 Swift 5。

Still Works, Swift 5 Update
  datePicker.setValue(UIColor.white, forKeyPath: "textColor") 

这对我有用。

datePicker.setValue(UIColor.whiteColor(), forKeyPath: "textColor")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM