美文网首页
iOS 设置view 三个角圆角

iOS 设置view 三个角圆角

作者: 乔布斯瞧不起 | 来源:发表于2021-09-14 11:47 被阅读0次

效果图

截屏2021-09-14 上午11.38.58.png

代码,复制走直接使用

-(void)setViewThreeCorner:(UILabel *)lable
{
    lable.font = [UIFont boldSystemFontOfSize:19];
    lable.textAlignment = NSTextAlignmentCenter;
    lable.backgroundColor = [UIColor redColor];
    lable.textColor = [UIColor whiteColor];
    // 设置右下角、右上角、左上角 圆角
    UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:lable.bounds
                                          byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight | UIRectCornerTopLeft
                                              cornerRadii:CGSizeMake(lable.bounds.size.height, lable.bounds.size.height)];
    CAShapeLayer *layer = [[CAShapeLayer alloc] init];
    layer.path = bezierPath.CGPath;
    lable.layer.mask = layer;
}

相关文章

网友评论

      本文标题:iOS 设置view 三个角圆角

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