iOS 设置view 三个角圆角

效果图

截屏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 三个角圆角)