我想在我的项目中自定义选择器视图。在pickerview cell& amp;中添加不同类型的图像也希望减少pickerview
身高。
我向你展示了更多理解的形象。
请帮帮我。 如何实现这种类型的pickerview.I检查自定义演示,但我没有找到
答案 0 :(得分: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;
}