UIView

2020-08-06  本文已影响0人  夜雨聲煩_

部分圆角

新建UIView分类

- (void)setPartRoundWithCorners:(UIRectCorner)corners cornerRadius:(float)cornerRadius{
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)].CGPath;
    self.layer.mask = shapeLayer;
}

使用

[view setPartRoundWithCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadius:20];
上一篇 下一篇

猜你喜欢

热点阅读