Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
527 views
in Technique[技术] by (71.8m points)

iphone - Customize UIPickerView's Skin with images

I am developing an iPhone application. Where in, I want to have UIPickerView as in the image. Is it possible to change the appearance of UIPickerView like this?! Please guide me to do this!! I am creating it without XIB.

Or is there a way to make UIPickerView skin transparent?

Sample UIPickerView Image

Thanks in advance!! :-)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I dont know this is a correct way or not but you can set your UIPickerView background image ... I have done it once.

See this :-

//Make a view to set as background of UIPickerView
UIView * viewForPickerView = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 216.0)];
[viewForPickerView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"pickerViewBackground.png"]]];

[[[pickerView subviews]objectAtIndex:2] addSubview: viewForPickerView];

//UIPickerView has 8 subviews like, background, rows, container etc.
// hide unnecessary subview

[(UIView*)[[pickerView subviews] objectAtIndex:3] setHidden:YES];
[(UIView*)[[pickerView subviews] objectAtIndex:5] setHidden:YES];
[(UIView*)[[pickerView subviews] objectAtIndex:6] setHidden:YES];
[(UIView*)[[pickerView subviews] objectAtIndex:7] setHidden:YES];
[(UIView*)[[pickerView subviews] objectAtIndex:8] setHidden:YES];

And now add a UILabel just on your UIPickerView's selectionIndicator, and use label as a selectionIndicator. you can manage it in your own way.

Thank you!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...