views:

2449

answers:

6

Hi

I want to change the border color of a UIPickerView. I do not see a tint property for the UIPickerView. Is there any way this could be done? Or a workaround?

Thanks.

+3  A: 

If you just want a workaround, take a screen shot in the simulator, open it in photoshop, crop it to just the UIPickerView area, make the center transparent, apply whatever tint you want, add that image to your project, and add it as a UIImageView on top of the UIPickerView.

Ed Marty
Thanks. No other way we can change the tint?
lostInTransit
I believe the background is just an image anyway, so it's likely that even if you were able to find the element in the subviews, it wouldn't be tint-able.
Ed Marty
how to change whole background color of the UIPickerView ? I try customize the view use the method '- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view" although the row view was updated but the left content of the Picker still show original gray color ... how to solve it ? thanks...
Robin
A: 

hey u cannot subview the UIPickerview please suggest some other way

Nirmit Patel
A: 

This suggestion actually is a good work around - the only thing is you need to create left, right, top, bottom images to overlay the UIPickerView so the picker is still selectable. Otherwise you will mask it so it cannot be accessed.

wrong, just make sure user interaction is disabled on the image view.
sbwoodside
+2  A: 

My UIPickerView has 3 components. And no Selection Indicator.

This gives it 11 subviews. [[picker subviews] count]

Hiding the first and the last subview totally removes the background.

[(UIView*)[[picker subviews] objectAtIndex:0] setHidden:YES]; [(UIView*)[[picker subviews] objectAtIndex:10] setHidden:YES];

Hiding every third other subview (indexes 1, 4 and 7) hides the opaque background on the components. Giving quite a nice effect that I can skin as I desire.

Hope that helps someone :)

adam
Isn't this really a hack? Apple could reject an app for doing this...
lostInTransit
[[picker subviews] count] returns 0. (Xcode 3.2.1)
Ben
A: 

Actualy to correct you, you actualy can put a .png ontop of the UIPickerview and still use the Picker View, just make sure the middle is transparent or you won't see the rows.

Jaba
A: 

I believe this article will be also helpful.

Eonil