/**
view 传入要变圆角的视图
size自己根据需要设置角度大小
后面的4个角 BOOL 1 是设置该角为圆角 0 不改变
*/
- (void)renYiYuanJiao:(UIView *)view size:(CGSize)size left:(BOOL)left right:(BOOL)right bottomLeft:(BOOL)bottomLeft bottomRight:(BOOL)bottomRight {
UIRectCorner Left = 0;
UIRectCorner Right = 0;
UIRectCorner BottomLeft = 0;
UIRectCorner BottomRight = 0;
if (left) {
Left = UIRectCornerTopLeft;
}
if (right) {
Right = UIRectCornerTopRight;;
}
if (bottomLeft) {
BottomLeft = UIRectCornerBottomLeft;
}
if (bottomRight) {
BottomRight = UIRectCornerBottomRight;
}
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:Left|Right|BottomLeft|BottomRight cornerRadii:size];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view.bounds;
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;
}
网友评论