我有一种方法可以在10之前的iOS版本上更改UIDatePicker的文本颜色,但是对于iOS10,这些解决方案似乎不再起作用.如何恢复更改UIDatePicker的textColor的功能? if #available(iOS 10.0, *) { //Not sure of
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)
}
似乎没有任何改变,因为我甚至可以使用Swift 3实现它,如下所示.
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()
}
}
