AppreciateIt AppreciateIt - 11 months ago 263
Swift Question

Change UIDatePicker TextColor in iOS10

I had a method of changing the

's text color on versions of iOS before 10, but with iOS10 those solutions no longer appear to work. How could I restore the ability to change the
for a

if #available(iOS 10.0, *) {
//Not sure of a way to do something similar here.
} else {
//The following lines change the textColor of UIDatePicker to white in iOS9 and older.
self.setValue(UIColor.white, forKey: "textColor")
self.sendAction(Selector("setHighlightsToday:"), to: nil, for: nil)

Answer Source

Nothing seems to have changed because I am able to achieve it even using Swift 3 as shown below.

import UIKit

class ViewController: UIViewController
    override func viewDidLoad()

        let temp: UIDatePicker = UIDatePicker(frame: self.view.frame)
        temp.setValue(UIColor.purple, forKey: "textColor")


    override func didReceiveMemoryWarning()