使用图像自定义UIPickerView的皮肤 [英] Customize UIPickerView's Skin with images

查看:77
本文介绍了使用图像自定义UIPickerView的皮肤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个iPhone应用程序。在哪里,我想在图像中有 UIPickerView 。是否可以像这样更改 UIPickerView 的外观?!请指导我这样做!!我在没有XIB的情况下创建它。

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.

或者有没有办法让 UIPickerView 皮肤透明?

Or is there a way to make UIPickerView skin transparent?

提前致谢!! : - )

Thanks in advance!! :-)

推荐答案

我不知道这是否正确但你可以设置你的 UIPickerView 背景图片......我已经完成了一次。

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

看到: -

//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];

现在只需添加一个 UILabel UIPickerView selectionIndicator ,并使用 标签 作为 selectionIndicator
你可以用自己的方式管理它。

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.

谢谢!

这篇关于使用图像自定义UIPickerView的皮肤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆