DanielPetters386
DanielPetters386

Reputation: 133

Setting the text colour of a UIDatePicker in Swift

I need to set the text colour of my Date Picker to white, i have had a look around and have tried to set it by creating a keyPath called "textColor" of type "Color" and then setting the colour, this works fine but the current date stays black. Does anyone have a solution for this?

Upvotes: 0

Views: 1839

Answers (2)

Marc
Marc

Reputation: 216

I think you are searching for this:

datePicker.setValue(UIColor.whiteColor(), forKey: "textColor")
datePicker.performSelector("setHighlightsToday:", withObject:UIColor.whiteColor())

Upvotes: 2

Mr.Geeker
Mr.Geeker

Reputation: 445

You can use

datePicker.setValue(UIColor.whiteColor(), forKeyPath: "Color")

Or try

https://i.sstatic.net/9Z1xG.png

another way to customise Picker

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

Upvotes: 2

Related Questions