2016-10-19 112 views
0

我想在我的项目中自定义选取器视图。在pickerview单元格中添加不同类型的图像&也希望降低pickerview高度。如何自定义选取器视图

我向你展示图像以获得更多理解。

enter image description here

请帮助我。 如何实现这种类型的pickerview.I检查自定义演示,但我没有找到

回答

0

将条件应用于UIPickerView的委托方法。

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ 
UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"your image number %@.png", (long)row]]; 
UIImageView *imageview= [[UIImageView alloc] initWithImage:img]; 
imageview.frame = CGRectMake(-70, 10, 60, 40); 

UILabel *channelLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, -5, 80, 60)]; 
channelLabel.text = [NSString stringWithFormat:@"%@", [myArray objectAtIndex:row]]; 
channelLabel.textAlignment = UITextAlignmentLeft; 
channelLabel.backgroundColor = [UIColor clearColor]; 

UIView *tmpView_row = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 110, 60)]; 
[tmpView_row insertSubview:imageview atIndex:0]; 
[tmpView_row insertSubview:channelLabel atIndex:1]; 

return tmpView_row; 
} 
相关问题