How to change selected color of date text in swift 3.0

This is my create code DataPicker

programmatically. I need to change the text color of the selected date to pink. But it is black by default. I used the below code but didn't work. I referenced several links but didn't work. thanks in advance How to change the text color of the current date datepicker?

self.datePicker = UIDatePicker(frame:CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 216))
self.datePicker.backgroundColor = UIColor.white
self.datePicker.datePickerMode = UIDatePickerMode.dateAndTime
textField.inputView = self.datePicker

      

+3


source to share


3 answers


The appearance of the UIDatePicker is not customizable. You should integrate date pickers into your layout using automatic layout. Although the date pickers are subject to change, they should be used according to their internal content Apple Doc size



If you want to customize the datepicker. you can use UIPickerView .

+1


source


try it



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

+1


source


you can use this:

dobDatePicker.setValue(UIColor.whiteColor(), forKeyPath: "textColor") dobDatePicker.setValue(false, forKey: "highlightsToday")

0


source







All Articles