有谁知道如何更改 UIDatePicker 的线条和字体颜色并避免使用私有(private) Apple api? 我找到了这个,但它是非常肮脏的解决方案:
datePicker.setValue(UIColor.white, forKey: "textColor")
for subview in self.datePicker.subviews {
if subview.frame.height <= 5 {
subview.backgroundColor = UIColor.white
subview.tintColor = UIColor.white
subview.layer.borderColor = UIColor.white.cgColor
subview.layer.borderWidth = 0.5 }
}
if let pickerView = self.datePicker.subviews.first {
for subview in pickerView.subviews {
if subview.frame.height <= 5 {
subview.backgroundColor = UIColor.white
subview.tintColor = UIColor.white
subview.layer.borderColor = UIColor.white.cgColor
subview.layer.borderWidth = 0.5
}
}
self.datePicker.setValue(UIColor.white, forKey: "textColor")
}
最佳答案
关于ios - 更改 datePicker 行和字体颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55005425/