iOS - view无限360度旋转和停止
2019-03-28 本文已影响0人
HanZhiZzzzz
- (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://blog.csdn.net/miaocuilin/article/details/70161438