jamshed jamshed - 2 years ago 199
iOS Question

iOS 9.2 UIDatePicker component currently selected component row's text color not changed

I can not change the font size of each component rows and currently selected component row's text color of UIDatePicker.

In ViewDidLoad, my code is :

self.dPicker.backgroundColor = [UIColor grayColor];
[self.dPicker setValue:[UIColor whiteColor] forKey:@"textColor"];

Is is limited by Apple?

enter image description here

Answer Source

There is no any API for change apperiance of UIDatePicker

then also if you want to do like that, you can do using swift:

See this for customizable implementation of UIDatePicker


If you want to change the color of selected row, then u need to change the font color or selection indicator of the row color

UIView *abc = [[UIView alloc] initWithFrame:CGRectMake(20, 130, 280, 44)];
abc.backgroundColor = [UIColor redColor];

abc.alpha = 0.5f;
[yourDatePicker addSubview: abc];

Try this for color:

yourDatePicker.backgroundColor = UIColor.redColor()
yourDatePicker.setValue(UIColor.blueColor(), forKeyPath: "textColor")
yourDatePicker.setValue(0.8, forKeyPath: "alpha")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download