顶角四舍五入的问题

时间:2017-07-17 11:02:36

标签: ios objective-c uitableview

第0节(细胞分离和单一选择)

enter image description here

第1节(细胞分组和多选) enter image description here

我使用下面的代码来圆顶角落。

//roundTop Method
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
                                                   byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
                                                         cornerRadii:CGSizeMake(10, 10)];

    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame = [[UIScreen mainScreen] bounds];
    maskLayer.path = maskPath.CGPath;
    maskLayer.lineJoin = kCALineJoinBevel;
    self.layer.masksToBounds = YES;
    self.layer.mask = maskLayer;
    [self drawBorderLayer:maskPath];

-(void)drawBorderLayer:(UIBezierPath *)maskPath {
    if (self.layer.borderWidth > 0) {

        CAShapeLayer*   frameLayer = [CAShapeLayer layer];
        frameLayer.frame = self.bounds;
        maskPath.lineWidth = self.layer.borderWidth * 2;
        frameLayer.path = maskPath.CGPath;
        frameLayer.strokeColor = self.layer.borderColor;
        frameLayer.fillColor = nil;
        [self.layer addSublayer:frameLayer];

    }
}
  • 我的圆角有问题。我添加了drawBorderLayer方法来绘制圆形部分的边框,但它没有足够的宽度。 (绿箭 - A)
  • 当我向下滚动时,圆形单元格被替换为另一个单元格(我无法正确重用单元格)。即。应用角质面罩后如何重置我的正常视图? 注意:我尝试了self.layer.mask = nil;,但没有尝试

我的cellForRowAtIndexpath

if (sectionModel.sectionStyle == SMFilterSectionStyleGrouped) {
        if ([[sectionModel.cells lastObject] isEqual:cellModel]) {
            [cell roundBottom];
        }else if(indexPath.row == 0) {
            [cell roundTop];
        }
    }

0 个答案:

没有答案