-4

我有一个像这样的自定义水平 UIPickerView 我想像这样更改图像

我不知道该怎么做。

4

1 回答 1

0

我试过这段代码

[[[self._picker1  subviews] objectAtIndex:3] setAlpha:0.0]; // this view contains the background so you can change it with your new background
// object at index 4 is your labels or images so they must be shown
[[[self._picker1  subviews] objectAtIndex:5] setAlpha:0.0];
[[[self._picker1  subviews] objectAtIndex:6] setAlpha:0.0];// this is you indicator , you can add another custom one or hide it as i do

//other views are about shadow in the right and left i set the alpha to 0.0 and i can also remove them
[[[self._picker1  subviews] objectAtIndex:7] setAlpha:0.0];
[[[self._picker1  subviews] objectAtIndex:8] setAlpha:0.0];
[[[self._picker1  subviews] objectAtIndex:0] setAlpha:0.0];
[[[self._picker1  subviews] objectAtIndex:1] setAlpha:0.0];

并在此处设置自定义图像是代码

UIView * viewForPickerView1 = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, self._picker1.frame.size.width, self._picker1.frame.size.height)];
[viewForPickerView1 setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"picker1.png"]]];
[[[self._picker1  subviews] objectAtIndex:2] addSubview:viewForPickerView1];

我希望它会帮助你

于 2013-09-30T09:48:51.307 回答