CAShapeLayer *shapeLayer=[CAShapeLayer layer];
shapeLayer.strokeColor=[UIColor cyanColor].CGColor;
shapeLayer.lineWidth=4;
[self.view.layer addSublayer:shapeLayer];
CABasicAnimation *pathAnimation=[CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.fromValue=@0;
pathAnimation.toValue=@1;
pathAnimation.duration=5;
[shapeLayer addAnimation:pathAnimation forKey:@"path"];
UIBezierPath *bezierPath=[UIBezierPath bezierPath];
//开始点
[bezierPath moveToPoint:CGPointMake(35, 400)];
//终点
[bezierPath addLineToPoint:CGPointMake(35, 200)];
shapeLayer.path=bezierPath.CGPath;
//开始点
[bezierPath moveToPoint:CGPointMake(35, 200)];
//终点
[bezierPath addLineToPoint:CGPointMake(200, 200)];
shapeLayer.path=bezierPath.CGPath;
iOS开发(OC)——路径动画
最新推荐文章于 2021-11-22 16:09:14 发布