动画--字 线

不错的文章

http://www.cocoachina.com/gamedev/misc/2013/1218/7569.html

待查看的文章

http://blog.sina.com.cn/s/blog_8efe12c90100y85g.html (原理篇)

http://blog.csdn.net/zhoutao198712/article/details/20864143

搜索关键字:strokeEnd

直接放源码:

   

-(void)startDrawingLineAnimation
{
    CAShapeLayer *layer =(CAShapeLayer *) self.fiveView.shapeLayer;
    layer.fillColor = [UIColor redColor].CGColor;
    layer.lineWidth = 10;
    layer.strokeColor = [UIColor blueColor].CGColor;
    
    //创建动画
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:NSStringFromSelector(@selector(strokeEnd))];
    animation.fromValue = @0.0;
    animation.toValue = @1.0;
    animation.delegate = self;
    animation.duration = 10;
    [layer addAnimation:animation forKey:NSStringFromSelector(@selector(strokeEnd))];
    
    //无需上下文
    UIBezierPath *path = [[UIBezierPath alloc] init];
    path.lineWidth = 10;
    [path moveToPoint:CGPointMake(200, 200)];
    //设置路径的颜色和动画
    CGPoint point = CGPointMake(100, 400);
    [path appendPath:[UIBezierPath bezierPathWithArcCenter:point radius:60 startAngle:0.0 endAngle:2 * M_PI clockwise:YES]];
    layer.path = path.CGPath;
}

你可能感兴趣的:(动画--字 线)