美文网首页
设置视图部分圆角

设置视图部分圆角

作者: 路漫漫其修远兮Wzt | 来源:发表于2019-11-21 14:51 被阅读0次

原文链接:https://blog.csdn.net/timtian008/article/details/80702462

+ (instancetype)bezierPathWithRoundedRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius

设置视图部分圆角问题,只需要设置 layer.cornerRadius

部分圆角

UIRectCorner有五种
UIRectCornerTopLeft //上左
UIRectCornerTopRight //上右
UIRectCornerBottomLeft // 下左
UIRectCornerBottomRight // 下右
UIRectCornerAllCorners // 全部

failLabel = [UILabel new];
failLabel.textColor = [UIColor whiteColor];
failLabel.font = APP_TEXT_FONT_20;
failLabel.backgroundColor = kColorFF3333;
failLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView  addSubview:failLabel];
failLabel.whc_LeftSpace(HGADPT(30)).whc_TopSpace(HGADPT(20)).whc_Height(HGADPT(32)).whc_Width(HGADPT(120));
failLabel.text = @"即将到期";

CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = [UIBezierPath bezierPathWithRoundedRect:failLabel.bounds byRoundingCorners:  UIRectCornerBottomRight cornerRadii: (CGSize){ 5.0f}].CGPath
failLabel.layer.masksToBounds = YES;
failLabel.layer.mask = maskLayer;

相关文章

网友评论

      本文标题:设置视图部分圆角

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