iOS开发(OC)——路径动画

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;

你可能感兴趣的:(OC)