Peter Warbo Peter Warbo - 6 months ago 44
Objective-C Question

Modify UIDatePicker selection indicator tint color

Is it possible to modify the tint color of a

UIDatePicker
's selection indicator? Or can it be removed so I can add my own selection indicator image?

I know in the case of
UIPickerView
´s you can disable the selection indicator so that you can provide your own selection indicator image.

Answer

There is no option to change the color of selection indicator by default. You can make a workaround though. I would add a simple UIView with a color of your choice and alpha value for transparency. Se the size and coordinates accordingly to the original selection indicator to overlay it (size 280x44, coordinates 20/130 for standard picker - not sure about that so find out the right values in case these don't match).

UIView *overlayIndicator = [[UIView alloc] initWithFrame:CGRectMake(20, 130, 280, 44)];
overlayIndicator.backgroundColor = [UIColor redColor];
overlayIndicator.alpha = 0.5f;
[yourDatePicker addSubview:overlayIndicator];

Hope it's something you can start with.

enter image description here