Set text color and font for UIDatePicker in iOS8/Swift

Fenda picture Fenda · Feb 9, 2015 · Viewed 32.5k times · Source

I've been having trouble trying to set the UIDatePicker font and color. Everything else in my app was fairly straightforward to adjust except this. Does anybody know how to do this? I'm using Swift for iOS8.

screenshot

Answer

Dylan Reich picture Dylan Reich · Nov 1, 2015

Changing the date mode to something else seems to force a re-draw with the newly set text color.

datePicker.setValue(UIColor.whiteColor(), forKeyPath: "textColor")
datePicker.datePickerMode = .CountDownTimer
datePicker.datePickerMode = .DateAndTime //or whatever your original mode was