使用UIBezierPath给视图添加圆角

- (UIView *)clipView:(UIView *)originView roundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii{
    UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:originView.bounds byRoundingCorners:corners cornerRadii:cornerRadii];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = originView.bounds;
    maskLayer.path = maskPath.CGPath;   // 轨迹
    originView.layer.mask = maskLayer;
    return originView;
}

你可能感兴趣的:(使用UIBezierPath给视图添加圆角)