Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change UIPicker Color ? iPhone

I have observed that UIPicker always remains in black color,

Is there any way to change the color of UIPicker & it's Selection Indicator?

Thanks for helping me.

like image 910
Sagar Kothari Avatar asked Dec 03 '22 07:12

Sagar Kothari


1 Answers

I assume all you want to change is the color of the border of the picker, not of the region in the center with which the user interacts. In this case, do the following:

Create 4 "cover" UIViews and add them directly to the UIPicker, as in:

[picker addSubview: coverView];

Position these views over the top, bottom, left and right sides of the picker border. (You will need to experiment with sizes.) Set the backgroundColor of the coverViews to the color you want, and adjust the alpha to get the gradient shading from the picker. Again, this may take a bit of experimentation.

The alternative would be to create one big coverView that covers the entire picker, and override the - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event method so that your cover view did not intercept the touches meant for the picker.

like image 53
Amagrammer Avatar answered Dec 21 '22 08:12

Amagrammer