美文网首页
给UIView指定角设置圆角

给UIView指定角设置圆角

作者: RichieQ | 来源:发表于2019-10-17 09:13 被阅读0次

通过UIRectCornerUIBezierPath组合给进行设置

// cornerRadius圆角大小,cornerRadius指定角
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
    maskLayer.maskLayer.frame = self.bounds;
    maskLayer.path = maskPath.CGPath;
    self.layer.mask = maskLayer;

Demo

相关文章

网友评论

      本文标题:给UIView指定角设置圆角

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