views:

2057

answers:

2

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.

+2  A: 

You can create your own custom pickers, check the UICatalog sample project at apples site, they show how to make a custom picker, it might help you https://developer.apple.com/iphone/library/samplecode/UICatalog/

Daniel
@Daniel - thanks for the nice tutorial. But I didn't find any solution for changing color of UIPicker
sugar
FYI, the custom picker (third choice in the UISegmentedController on that page of the UICatalog application) has a defect: you lose the ability to select a value in the picker by simply touching it. This problem has been there from the beginning and Apple has not fixed it yet. It happens any time you customize the views inside the picker.
Amagrammer
+3  A: 

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.

Amagrammer