Change UIDatePicker font color? Change UIDatePicker font color? ios ios

Change UIDatePicker font color?


All I need (on iOS 8.x and 9.0) is this one line to change the font color:

        [my_date_picker setValue:[UIColor whiteColor] forKey:@"textColor"];

No subclassing or invoking of private APIs...


Note: today's current date will still be highlighted (in newer iOS versions). You can get around this by using the following code:

if ([my_date_picker respondsToSelector:sel_registerName("setHighlightsToday:")]) {#pragma clang diagnostic push#pragma clang diagnostic ignored "-Wundeclared-selector"        [my_date_picker performSelector:@selector(setHighlightsToday:) withObject:[NSNumber numberWithBool:NO]];#pragma clang diagnostic pop}


As of Swift 2.1:

picker.setValue(UIColor.whiteColor(), forKey: "textColor")picker.sendAction("setHighlightsToday:", to: nil, forEvent: nil)let date = NSDate()picker.setDate(date, animated: false)

Instead of "today" you will see the current day,


One other alternative to @Jeremiah answer is to define those values in Interface Builder.I prefer this one because there is no code to add in your ViewController.

Click into your DatePicker view and customise it from the Attribute inspector as in the screenshot.screenshot

Works for Swift 2, 3, 4 and probably for Swift < 2. (not tested)