Change UIDatePicker font color?

后端 未结 15 1815
南方客
南方客 2020-12-04 19:12

All I want to do is change the font color of the UIDatePicker. I\'ve researched other questions but they\'re all involving changing other properties and customizing the enti

15条回答
  •  再見小時候
    2020-12-04 20:09

    As alternative to @Jeremiah answer, you can use this:

    datePicker.setValue(UIColor.redColor(), forKey: "textColor")
    datePicker.sendAction("setHighlightsToday:", to: nil, forEvent: nil)
    datePicker.setDate(NSDate(timeIntervalSinceReferenceDate: 0), animated: false)
    

    it will remove Today (you will see current date), but it will be with right color.

    Possible troubles: if you change color dynamically, I didn't find a way to reload date picker. So, the user will see previous color and only after scroll, color will changed to a new one. -> Solved, by last string. Looks like Voodoo, but it works...

    This answer suitable for Swift 2.1

提交回复
热议问题