好久没有写过博客了,一个原因是项目时间很紧,一直在写项目,工作之余也在优化性能,也没有时间在想记录一下学习状态,另一个原因很简单,不想在写一些重复的知识,没什么技术含量
这周闲来无事,就写一篇记录一下自己
/**
创建贝塞尔曲线
画一个圆弧
*/
- (void)CreatBeziePath
{
self.layer = [CAShapeLayer layer];
self.layer.frame = CGRectMake(0, 0, 400, 400);//设置layer的尺寸和位置
self.layer.position = self.view.center;
self.layer.fillColor = [UIColor clearColor].CGColor;//填充颜色
//设置线条的宽度和颜色
self.layer.lineWidth = 1.0f;
self.layer.strokeColor = [UIColor redColor].CGColor;
//创建出圆行的贝塞尔曲线
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 400, 400)];
//让贝塞尔曲线与layer产生联系
self.layer.path = path.CGPath;
//添加并显示
[self.view.layer addSublayer:self.layer];
self.layer.strokeStart = 0;//圆弧的起点
self.layer.strokeEnd = 0.3; //控制圆弧的大小
}
- (void)creatCurvedLine
{
UIBezierPath *Apath = [UIBezierPath bezierPath];
Apath.lineWidth = 5.0;
Apath.lineCapStyle = kCGLineCapRound;//线条拐角
Apath.lineJoinStyle = kCGLineCapRound; //终点处理
[Apath moveToPoint:CGPointMake(20, 100)];
[Apath addQuadCurveToPoint:CGPointMake(120, 100) controlPoint:CGPointMake(70, 0)];
self.layer = [CAShapeLayer layer];
self.layer.path = Apath.CGPath;
[self.view.layer addSublayer:self.layer];
}