ios - 如何自定义UIDatePicker并改变文字颜色和背景颜色?

标签 ios swift uitableview uidatepicker

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

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

第一个屏幕截图是实际的意外结果:

The actual UIDatepicker

第二个截图是想要的结果:

enter image description here

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

最佳答案

@AziCode

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

targetedDatePicker.backgroundColor = UIColor.blueColor()
targetedDatePicker.setValue(UIColor.greenColor(), forKeyPath: "textColor")
targetedDatePicker.setValue(0.8, forKeyPath: "alpha")

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

can I change the font color of the datePicker in iOS7?

关于ios - 如何自定义UIDatePicker并改变文字颜色和背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31192463/

相关文章:

iphone - 将文件添加到特定构建配置的目标

ios - 如何删除 Xcode 警告 Apple Mach-O Linker Warning 'Pointer not aligned at address

ios - 谁能解释一下这个 NSPredicate 语法

swift - 将个人资料图像字符串从 firebase 数据库下载到 uiimage

swift - Swift 运行时如何处理元组?

ios - 在 IOS 的 ImageView 中从 API 多次加载图像

iphone - 点击状态栏时间

android - 适用于 Android 和 iOS 的视频/音频框架

ios 6 UITableViewCell 删除按钮有背景色

ios - 如果某些数据为 NSNull,如何正确解析 JSON 数据