我有一种方法可以UIDatePicker
在10之前的iOS版本上更改的文本颜色,但是在iOS10上,这些解决方案似乎不再起作用。我该如何恢复更改textColor
for的功能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)
}
似乎没有任何变化,因为即使使用如下所示的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()
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句