All I want to do is change the font color of the UIDatePicker. I've researched other questions but they're all involving changing other properties and customizing the entire look. All I want to do is just change the font color from black to white. I find it hard to believe that I can't do such a seemingly simple task. And why wouldn't the tint color affect it? Does it even do anything?
Open your device's Settings app . Text and display. Select Color correction. Turn on Use color correction.
Xcode Getting started with Xcode Changing The Color SchemeWith the preference pane open you can click on the 'Fonts and Colors' tab. From here you can change the source AND console background and font colors.
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,
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