贝塞尔曲线处理圆角

  • .h文件
@interface LYBezierPath : NSObject

/**
 圆角处理

 @param view 需要圆角化的视图
 @param corners 需要圆角的边角
 @param radii 需要圆角的尺寸
 @return CAShapeLayer
 */
+(CAShapeLayer *)superView:(UIView *)view
                   Corners:(UIRectCorner)corners
                     Radii:(CGSize)radii;

@end
  • .m文件

@implementation LYBezierPath

+(CAShapeLayer *)superView:(UIView *)view
                   Corners:(UIRectCorner)corners
                     Radii:(CGSize)radii{
    
    UIBezierPath *maskPath = [UIBezierPath
                              bezierPathWithRoundedRect:view.bounds
                              byRoundingCorners:corners
                                  cornerRadii:radii];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = view.bounds;
    maskLayer.path = maskPath.CGPath;
    return maskLayer;
    
}

@end

你可能感兴趣的:(贝塞尔曲线处理圆角)