2010-04-22 78 views
0

如何更改UIPickerview的风格。我想将其白色背景更改为绿色,将其黑色框更改为红色。 任何人都请帮忙。我是一名初学者。更改UIPickerView的风格

回答

1

据我知道你不能真正改变框的颜色,但你可以在中间的透明区域创建图像,并补充说,在框架的顶部,像这样:

[picker addSubview:image]; 

- (UIView *)pickerView:(UIPickerView *)pickerView 
         viewForRow:(NSInteger)row 
         forComponent:(NSInteger)component 
         reusingView:(UIView *)aView; 

你可以再设置你通过

返回视图的背景颜色:作为背景色,你可以通过实现 UIPickerViewDelegate方法创建的每一行自己的自定义视图
[myView setBackgroundColor:[UIColor yellowColor]]; 

但是,这只会影响包含数据的行。我不认为你现在可以设置组件本身的背景颜色,这是一个耻辱。

0

我个人比较喜欢这样的:

[self.picker setBackgroundColor:[UIColor greenColor]]; 
self.picker.layer.borderColor = [UIColor whiteColor].CGColor; 
self.picker.layer.borderWidth = 4;