Changing a picker view's background color and text color
suggest changetextColor is not a public UIPickerView property. Setting it with setValue:forKey: depends on the picker’s private view structure and can stop working.
Objective-C
// Displays the country picker with a black background and white text
[self.countryPicker setValue:[UIColor whiteColor] forKey:@"textColor"];
[self.countryPicker setValue:[UIColor blackColor] forKey:@"backgroundColor"];
Swift
let color1 = UIColor(red: 1, green: 1, blue: 1, alpha: 1)
let color2 = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
pickerView2.setValue(color1, forKey: "textColor")
pickerView2.setValue(color2, forKey: "backgroundColor")
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents