In my custom cell I have written [self setClipsToBound : YES]
and then adding these red imageViews as its subviews as [self addSubview:imageView]
But as you can see the imageView is not getting clipped.
I searched, but din't find any success!
In my custom cell I have written [self setClipsToBound : YES]
and then adding these red imageViews as its subviews as [self addSubview:imageView]
But as you can see the imageView is not getting clipped.
I searched, but din't find any success!
是的,问题是您的分组表格视图,分组表格视图单元格与普通表格视图具有相同宽度的事实非常不直观,唯一的区别是分组表格视图具有不同的单元格背景(也适用于选定状态)以及由单元格标签的不同位置创建的单元格内容的边距。
您应该创建右上角和右下角圆角的资产(对于一个部分的第一个单元格和最后一个单元格)。clipSubview 不适用于您的情况,因为 imageView 没有丰富的单元格内容。
使用以下代码将图像添加到分组单元格的背景。
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, yourCell.frame.size.width, 80)]; // Modify this for your cell
imgView.contentMode = UIViewContentModeScaleAspectFit;
cell.backgroundColor = [UIColor colorWithPatternImage:imgView.image];