iOS view无限360度旋转和停止

    xiaoxiao2021-04-14  68

    - (void)rotateView:(UIImageView *)view

    {

        CABasicAnimation *rotationAnimation;

        rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

        rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI*2.0];

        rotationAnimation.duration = 1;

        rotationAnimation.repeatCount = HUGE_VALF;

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

    }

    如上代码,传入要旋转的view即可。

    如果想要停止:

    [self.playStatusImageView.layer removeAllAnimations];//停止动画

    即可。
    转载请注明原文地址: https://ju.6miu.com/read-669846.html

    最新回复(0)