美文网首页
简单的圆弧动画

简单的圆弧动画

作者: 40dd4b561abe | 来源:发表于2017-08-23 12:00 被阅读3次
    
    UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150) radius:100 startAngle:0 endAngle:M_PI*2 clockwise:YES];
//    path.lineWidth = 10;
    CAShapeLayer  * layer = [[CAShapeLayer alloc]init];
    layer.frame = view.bounds;
    layer.path = path.CGPath;
    layer.lineWidth = 10;
    layer.strokeColor = [UIColor yellowColor].CGColor;
//    layer.fillColor = [UIColor clearColor].CGColor;
    layer.backgroundColor = [UIColor redColor].CGColor;

    [view.layer addSublayer:layer];


    CABasicAnimation * animation = [[CABasicAnimation alloc]init];
    animation.fillMode=kCAFillModeForwards ;//保持动画后的状态
    animation.keyPath = @"strokeEnd";
    animation.fromValue = [NSNumber numberWithInteger:1];
    animation.toValue = [NSNumber numberWithInteger:0];
    animation.duration = 2;
    animation.removedOnCompletion= NO;
    [layer addAnimation: animation forKey:@""];

相关文章

网友评论

      本文标题:简单的圆弧动画

      本文链接:https://www.haomeiwen.com/subject/vbsddxtx.html