//指定矩形大小
CGRect rect =CGRectMake(50, 300, 100, 100);
//设置圆角半径
CGSize size =CGSizeMake(20, 20);
//拿出需要设置改动的角
UIRectCorner corners = UIRectCornerBottomRight;
//综合上两部的具体操作
UIBezierPath * rectPath =[UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:corners cornerRadii:size];
//图形子类来渲染
CAShapeLayer * rectLayer =[CAShapeLayer layer];
//线条颜色
rectLayer.strokeColor =[UIColor greenColor].CGColor;
//填充颜色
rectLayer.fillColor =[UIColor orangeColor].CGColor;
//线条宽度
rectLayer.lineWidth =5;
//起始结束点的样式
rectLayer.lineJoin =kCALineJoinRound;
//线条拐角的样式
rectLayer.lineCap =kCALineCapRound;
rectLayer.path =rectPath.CGPath;
[self.view.layer addSublayer:rectLayer];
如何让控件只有一个圆角
最新推荐文章于 2025-03-14 11:35:51 发布