I am trying to change the text color for UIDatePicker using setValue() function, but I don't see any change on the UI. I am displaying date picker on a UITableViewCell and testing it on iOS 15 device.
How can I change the text color for date picker? I also want to change highlight color for Today, but my app is crashing when I uncomment the setValue() line for "highlightsToday" in below code.
Below is my code:
func formatCell(checkInDate: Date) {
dateTimePicker.setValue(UIColor.red, forKeyPath: "textColor")
// dateTimePicker.setValue(false, forKeyPath: "highlightsToday")
dateTimePicker.addTarget(self, action: #selector(handler(_:)), for: UIControl.Event.valueChanged)
dateTimePicker.date = checkInDate
dateTimePicker.minuteInterval = 30
dateTimePicker.datePickerMode = .dateAndTime
dateTimePicker.minimumDate = Date().nearest30Mins()
if #available(iOS 13.4, *) {
dateTimePicker.preferredDatePickerStyle = .compact
}
}