美文网首页
UILabel圆化指定角

UILabel圆化指定角

作者: Felix的笔头 | 来源:发表于2017-09-01 18:47 被阅读0次

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(30, 200, 200, 20)];

label.backgroundColor = COLOR_FF574E;

UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:label.bounds byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerTopLeft cornerRadii:CGSizeMake(5, 5)];

CAShapeLayer * maskLayer = [[CAShapeLayer alloc]init];

maskLayer.frame = label.bounds;

maskLayer.path = maskPath.CGPath;

label.layer.mask = maskLayer;

[self.view addSubview:label];

相关文章

网友评论

      本文标题:UILabel圆化指定角

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