利用贝塞尔曲线切不均匀的圆角

2018-12-08  本文已影响14人  ymhlbj
UIView *bgView = [TDHPCreateViewTool createView:[UIColor clearColor]];
[self addSubview:bgView];
 //利用班赛尔曲线画角
bgView.frame = CGRectMake(15, 14, SCREEN_WIDTH - 30, 42 - 14);
CAShapeLayer *maskLayer = [CAShapeLayer layer];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bgView.bounds byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)  cornerRadii:CGSizeMake(15, 15)]; //byRoundingCorners方向 cornerRadii 圆角的角度
maskLayer.path = maskPath.CGPath;
maskLayer.fillColor = [UIColor whiteColor].CGColor; //内容填充的颜色
maskLayer.strokeColor = rgb(255,255 ,255).CGColor; //边色
maskLayer.lineWidth = 1.0f; //*这里注意是lineWidth,区别于borderWidth
maskLayer.frame = bgView.bounds;
[bgView.layer addSublayer:maskLayer];
上一篇 下一篇

猜你喜欢

热点阅读