美文网首页iOS 适配
ios-给view添加部分圆角

ios-给view添加部分圆角

作者: songjk | 来源:发表于2020-07-17 10:28 被阅读0次

    以下例子为左上角和右上角添加圆角

    CGFloat radius = 10; // 圆角大小
    UIRectCorner corner = UIRectCornerTopLeft | UIRectCornerTopRight; // 圆角位置
    UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.imgView.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(radius, radius)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.imgView.bounds;
    maskLayer.path = path.CGPath;
    self.imgView.layer.mask = maskLayer;

    相关文章

      网友评论

        本文标题:ios-给view添加部分圆角

        本文链接:https://www.haomeiwen.com/subject/hdnwhktx.html