在iOS10中更改UIDatePicker TextColor [英] Change UIDatePicker TextColor in iOS10

查看:97
本文介绍了在iOS10中更改UIDatePicker TextColor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种方法可以在10之前的iOS版本上更改UIDatePicker的文本颜色,但是对于iOS10,这些解决方案似乎不再起作用.如何恢复为UIDatePicker更改textColor的功能?

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) 
   }

推荐答案

似乎没有什么改变,因为即使使用如下所示的Swift 3,我也能够实现它.

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()
    }
}

这篇关于在iOS10中更改UIDatePicker TextColor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆