How to change UIPicker Color ? iPhone

前端 未结 6 865
走了就别回头了
走了就别回头了 2020-12-30 17:35

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 hel

6条回答
  •  囚心锁ツ
    2020-12-30 18:35

    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.

提交回复
热议问题