美文网首页
利用贝塞尔曲线切不均匀的圆角

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

作者: ymhlbj | 来源:发表于2018-12-08 17:52 被阅读14次
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];

相关文章

网友评论

      本文标题:利用贝塞尔曲线切不均匀的圆角

      本文链接:https://www.haomeiwen.com/subject/qooqhqtx.html