AziCode AziCode - 2 years ago 575
Swift Question

How to customize the UIDatePicker and change the text color and the background color?

I have created a formatted display of a date object in a table cells and used UIDatePicker to edit those values.

But I am unable to edit the tint color of the text and the background color.

The first screenshot is the actual undesired result:

The actual UIDatepicker

The second screenshot is the desired result:

enter image description here

Here is a link to the project :

Max Max
Answer Source


Add the below line in your func updateDatePicker() , if you like to get the exact color use RGB color coding with UiColor

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

And refer the link and sample codes for same examples :-

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download