小编And*_*pez的帖子

如何在UIpickerView的特定行中插入图像和文本?

我已经实现了以下功能:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UIImage *img = [UIImage imageNamed:@"persona.jpeg"];
    UIImageView *temp = [[UIImageView alloc] initWithImage:img]; 
    temp.frame = CGRectMake(-70, 10, 60, 40);

    UILabel *channelLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, -5, 80, 60)];
    channelLabel.text = @"persona y";
    channelLabel.textAlignment = UITextAlignmentLeft;
    channelLabel.backgroundColor = [UIColor clearColor];

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

    return tmpView; 
}
Run Code Online (Sandbox Code Playgroud)

结果如下:

屏幕

我需要在特定的行中插入图像和文本,任何想法如何做?
非常感谢您的帮助.

我的想法是填充一系列图片和描述来填充UIPickerView

cocoa-touch uipickerview uikit ios

1
推荐指数
1
解决办法
4741
查看次数

标签 统计

cocoa-touch ×1

ios ×1

uikit ×1

uipickerview ×1