美文网首页
iOS - view无限360度旋转和停止

iOS - view无限360度旋转和停止

作者: HanZhiZzzzz | 来源:发表于2019-03-28 16:03 被阅读0次
- (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

相关文章

网友评论

      本文标题:iOS - view无限360度旋转和停止

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