如何自定义UIDatePicker并更改文本颜色和背景颜色?

Azi*_*ode 5 uidatepicker uitableview ios swift

我在表格单元格中创建了日期对象的格式化显示,并使用UIDatePicker编辑这些值.

但我无法编辑文本的色调颜色和背景颜色.

第一个屏幕截图是实际不需要的结果:

实际的UIDatepicker

第二个屏幕截图是所需的结果:

在此输入图像描述

以下是该项目的链接:https://www.dropbox.com/sh/m74tnghpqeah8o7/AAA-rMlGe_mhqiuEkDhbApsUa?dl=0

Max*_*Max 13

@AziCode

如果你想使用UiColor获得确切的颜色使用RGB颜色编码,请在func updateDatePicker()中添加以下行

targetedDatePicker.backgroundColor = UIColor.blueColor()
targetedDatePicker.setValue(UIColor.greenColor(), forKeyPath: "textColor")
targetedDatePicker.setValue(0.8, forKeyPath: "alpha")
Run Code Online (Sandbox Code Playgroud)

并参考相同示例的链接和示例代码: - http://blog.deeplink.me/post/81386967477/how-to-easily-customize-uidatepicker-for-ios

我可以在iOS7中更改datePicker的字体颜色吗?