Recently I work with the function func setValue(_ value: AnyObject?, forKey key: String)
of the NSKeyValueCoding
protocol to change the text color of a UIPickerDate
in the following way:
class ColoredDatePicker: UIDatePicker {
var changed = false
override func addSubview(view: UIView) {
if !changed {
changed = true
self.setValue(UIColor(red: 0.42, green: 0.42, blue: 0.42, alpha: 1), forKey: "textColor")
}
super.addSubview(view)
}
}
Regarding the answer in this question. It works perfectly.
But my answer here is:
How do I know what names that the class provide like the textColor
used above?.
I'm trying to find anything get all the names or in the documentation, but so far I don't find anything yet to get the keys provided by a class like in the above case.