在iOS8 / Swift中为UIDatePicker设置文本颜色和字体 [英] Set text color and font for UIDatePicker in iOS8/Swift

查看:1859
本文介绍了在iOS8 / Swift中为UIDatePicker设置文本颜色和字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直无法设置 UIDatePicker 字体颜色。我的应用程序中的其他所有内容都非常简单,除此之外。有人知道怎么做这个吗?我正在为 iOS8 使用 Swift

I've been having trouble trying to set the UIDatePicker font and color. Everything else in my app was fairly straightforward to adjust except this. Does anybody know how to do this? I'm using Swift for iOS8.

推荐答案

将日期模式更改为其他内容似乎强制执行使用新设置的文本颜色重新绘制。

Changing the date mode to something else seems to force a re-draw with the newly set text color.

datePicker.setValue(UIColor.whiteColor(), forKeyPath: "textColor")
datePicker.datePickerMode = .CountDownTimer
datePicker.datePickerMode = .DateAndTime //or whatever your original mode was

这篇关于在iOS8 / Swift中为UIDatePicker设置文本颜色和字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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