使用iOS14.0.1,Swift5.3,Xcode12.0.1,
我尝试在iOS14中使用UIKit更改UIDatePicker
的textColor
。
我在这里阅读到需要使用以下方法:
let myDatePicker = UIDatePicker()
myDatePicker.tintColor = .white
我还尝试了以下方法(但这会导致我的应用在iOS14下崩溃):
myDatePicker.setValue(UIColor.white, forKeyPath: "textColor")
我也尝试过(但也没有成功):
UILabel.appearance(whenContainedInInstancesOf: [UIDatePicker.self]).textColor = UIColor.white
在浅色模式下,我的尝试都无法正常工作(可以在屏幕截图中看到):
我需要做些什么才能让我的 UIDatePicker
文本是白色的?