I had a method of changing the UIDatePicker'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 textColor for a UIDatePicker?
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)
}
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()
{
super.viewDidLoad()
let temp: UIDatePicker = UIDatePicker(frame: self.view.frame)
temp.setValue(UIColor.purple, forKey: "textColor")
view.addSubview(temp)
}
override func didReceiveMemoryWarning()
{
super.didReceiveMemoryWarning()
}
}
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