快速旋转视图暂停

时间:2015-04-21 07:54:44

标签: ios swift rotation animatewithduration

我想进行无限旋转。但我看到一个旋转停顿。你能解释一下原因吗?

    UIView.animateWithDuration(0.5, delay: 0, options: UIViewAnimationOptions.Repeat | UIViewAnimationOptions.CurveLinear, animations:
        {
            self.myview.transform = CGAffineTransformRotate(self.myview.transform, CGFloat(M_PI_2))
        }, completion: { nil
        }()
    )

1 个答案:

答案 0 :(得分:0)

我想你想要UIView的循环轮换。你可以使用下面的代码实现。

 CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0  * 1 * 3 ];
    rotationAnimation.duration = 3;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 5;

    [btnPush.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];