Objective C,使一些角变圆,无法正常工作

Objective C, make some corner - rounded, not work correctly

我想在 table 视图中创建一个 topRight、bottomRight、bottomLeft 圆角和 topLeft 不圆角的项目。像这样:

我在我的方法中添加了一个“舍入代码”

    - (UITableViewCell *)tableView:(UITableView *)tableView
             cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
 UITableViewCell* cell = [super tableView:tableView
                       cellForRowAtIndexPath:indexPath];
                GOShadowContainerTableViewCell* commentCell = (GOShadowContainerTableViewCell*) cell; // my base class for cell
    
    // make rounded
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:commentCell.view1.bounds
                                                       byRoundingCorners:UIRectCornerBottomLeft| UIRectCornerTopRight | UIRectCornerTopLeft
                                                             cornerRadii:CGSizeMake(8.0, 8.0)];
    
        // Create the shape layer and set its path
        CAShapeLayer *maskLayer = [CAShapeLayer layer];
        maskLayer.frame = commentCell.view1.bounds;
        maskLayer.path = maskPath.CGPath;
        commentCell.view1.layer.masksToBounds = YES;
    
        // Set the newly created shape layer as the mask for the image view's layer
        view.layer.mask = maskLayer;
    
    
    }

我的 UI 单元层次结构

我的问题:当我第一次加载视图时,我有这样的列表:

然后我向下滚动然后向上滚动,一切看起来都不错

为什么它的工作方式“奇怪”?请帮助我弄清楚为什么它在第一次加载 tableview

时无法正常工作

这个呢..

圆形单元格视图的标准背衬层,并告诉图层在哪个角上应用圆形蒙版。

cell.layer.cornerRadius = 5.0;
// kCALayerMinXMinYCorner should be the upper left corner, so not used..
cell.layer.maskedCorners = kCALayerMaxXMinYCorner | kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;

没有检查..但看起来不错还是?