如何更改UIPickerView图像

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

我不知道该怎么办

我试过这个代码

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

我希望这会帮助你