简单的圆弧动画

2017-08-23  本文已影响3人  40dd4b561abe
    
    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:@""];
上一篇 下一篇

猜你喜欢

热点阅读