美文网首页
iOS部分圆角

iOS部分圆角

作者: YimG | 来源:发表于2021-06-01 15:52 被阅读0次

使用 CAShapeLayer + UIBezierPath 方式

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:VIEW.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(15, 0)];

CAShapeLayer * maskLayer = [[CAShapeLayer alloc]init];
maskLayer.frame = VIEW.bounds;
maskLayer.path = maskPath.CGPath;
VIEW.layer.mask = maskLayer;

typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
UIRectCornerTopLeft = 1 << 0, 【左上】
UIRectCornerTopRight = 1 << 1, 【右上】
UIRectCornerBottomLeft = 1 << 2, 【左下】
UIRectCornerBottomRight = 1 << 3, 【右下】
UIRectCornerAllCorners = ~0UL 【全部4圆角】
};

相关文章

网友评论

      本文标题:iOS部分圆角

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