So I'm facing this problem, the standard UIPicker doesn't look good in my (proto) app and I would really change its appearance. I've already googled it and found this useful link http://aralbalkan.com/2985. Looks good but I'm wondering if there isn't an easier way to do it.
Here on stack overflow I've found this thread Is it possible to 're-skin' the IOS Date Picker?, it's "unsolved" but pointing to the first article.
I also did a tutorial in Apress Book "Beginning Iphone development" (chapter 7 I think), very useful, but there I was changing just the content of the columns, not the full appearance of it. Just to be clear, it would be great to have something like this:
Anyone has a good tutorial/link/suggestion for an Objective-c rookie? Thx in advice
EDIT: So I've implemented the method detailed in the two answers below and it works like a charm. But I'm still stuck with the background color ....
the numbers shoud be able to create via using UIPickerViewDelegate
's pickerView:viewForRow:forComponent:reusingView:
, while the comma could be added via addSubView:
.
or you go down another road and use a open source alternative, i.e. AFPickerView
You can manipulate teh views in the hierarchy — but probably it is easier to recreate the picker …
-(void)viewDidAppear:(BOOL)animated
{
for (UIView *view in [self.pickerView subviews]) {
NSLog(@"%@", view);
}
[(UIView *)[[self.pickerView subviews] objectAtIndex:1] setBackgroundColor:[UIColor blueColor]];
[(UIView *)[[self.pickerView subviews] objectAtIndex:0] setHidden:YES];
[(UIView *)[[self.pickerView subviews] lastObject] setHidden:YES];
for (UIView *view in [(UIView *)[[self.pickerView subviews] objectAtIndex:2] subviews]) {
NSLog(@"> %@", view);
}
[[[(UIView *)[[self.pickerView subviews] objectAtIndex:2] subviews] lastObject] setHidden:YES];
}