2

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

Jamshed Alam
  • 12,424
  • 5
  • 26
  • 49

3 Answers3

1

According to Apple's UIKit User Interface Catalog, we are not allowed to customize date pickers.

I suggest you look at other StackOverflow answers for similar questions that suggest making a fake UIDatePicker using UIPickerView and customizing that.

Community
  • 1
  • 1
Cjay
  • 1,093
  • 6
  • 11
1

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

https://github.com/prolificinteractive/PIDatePicker

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")
Suraj Sukale
  • 1,778
  • 1
  • 12
  • 19
0

@jamshed You don't need create a subview and add it to UIDatePicker. If you want to change highlight text color of UIDatePicker, you can use this code:

[self.datePicker setValue:@(false) forKey:@"highlightsToday"];

tasumi
  • 1