My UIDatePicker's background is black (because the background for the whole screen is black probably), but I want white in the background for this UIDatePicker.
Is there any way to change the background color without subclassing it?
datePickerName.backgroundColor = [UIColor grayColor];
iOS 14 update
It looks that datePicker.backgroundColor
doesn't work in iOS 14. It works. But you have to put it after preferredDatePickerStyle
setting:
let picker = UIDatePicker()
if #available(iOS 13.4, *) {
picker.preferredDatePickerStyle = .wheels
}
picker.backgroundColor = .red
OBJECTIVE C
datePicker.backgroundColor = [UIColor greenColor]
SWIFT
DatePicker.backgroundColor = UIColor.blueColor()
DatePicker.setValue(UIColor.greenColor(), forKeyPath: "textColor")
DatePicker.setValue(0.8, forKeyPath: "alpha")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With