美文网首页iOS开发
iOS控件指定圆角设置

iOS控件指定圆角设置

作者: 智人一千 | 来源:发表于2019-07-23 15:51 被阅读0次

直接上代码

 //指定圆角
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: self.labProductLine.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(kSixScaleWidth(5),kSixScaleWidth(5))];
    //创建 layer
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.labProductLine.bounds;
    //赋值
    maskLayer.path = maskPath.CGPath;
    self.labProductLine.layer.mask = maskLayer;

指定哪个角设置圆角的枚举

typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
    UIRectCornerTopLeft     = 1 << 0,//左上角
    UIRectCornerTopRight    = 1 << 1,//右上角
    UIRectCornerBottomLeft  = 1 << 2,//左下角
    UIRectCornerBottomRight = 1 << 3,//右下角
    UIRectCornerAllCorners  = ~0UL//所有角
};

对你有帮助记得点小心心❤️

相关文章

网友评论

    本文标题:iOS控件指定圆角设置

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