我有一个单元格,里面有一些文本,我正在尝试向单元格添加图像。
这是我试过的:
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(30, 30, 30, 30)];
imageView.backgroundColor = [UIColor clearColor];
[imageView.layer setCornerRadius:5.0f];
[imageView.layer setMasksToBounds:YES];
[imageView setImage:[UIImage imageNamed:@"test2.jpeg"]];
[cell.contentView addSubview:imageView];
cell.imageView.clipsToBounds = YES;
这是现在的样子:
有没有办法避免图像与单元格中的文本重叠?提前致谢!
最佳答案
tableviewcells 有自己的 imageView,将显示在内容的左侧或至少显示在单元格文本的左侧。
您正在创建一个恰好具有相同名称的额外 imageView。
关于ios - UITableViewCell imageView 重叠单元格中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20863232/