Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change UIDatePicker selected Date text Color for Dark mode (iOS 13)

Having trouble to find out a solution for changing the color of text for the selected Date in iOS 13 dark mode.

I know how to change the color of the text of a UIPicker view using code

self.timePicker.setValue(UIColor.black, forKeyPath: "textColor")

OR using User Defined Runtime Attributes. But nothing is working for changing the selected date color for iOS 13 Dark mode. With background white color and black text color, my date picker-view looks like this:

enter image description here

So with changing the text color black, does not change the selected date text color. It changes all the other text color to black; but not the selected one. Selected one stays white, which is default for dark mode.

like image 432
A K M Saleh Sultan Avatar asked Sep 24 '19 20:09

A K M Saleh Sultan


1 Answers

You can set self.window inside AppDelegate.m and override Interface style like so

if (@available(iOS 13, *)) {
    self.window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
}
return YES;

Swift 5.*

if #available(iOS 13.0, *) {
    self.window?.overrideUserInterfaceStyle = .light
}
like image 129
copser Avatar answered Oct 17 '22 17:10

copser