iOS view无限360度旋转和停止

来源:互联网 发布:mac修容偏白用哪个色 编辑:程序博客网 时间:2024/05/21 21:01

- (void)rotateView:(UIImageView *)view

{

    CABasicAnimation *rotationAnimation;

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

    rotationAnimation.toValue = [NSNumbernumberWithFloat:M_PI*2.0];

    rotationAnimation.duration =1;

    rotationAnimation.repeatCount =HUGE_VALF;

    [view.layeraddAnimation:rotationAnimationforKey:@"rotationAnimation"];

}


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

如果想要停止:

[self.playStatusImageView.layerremoveAllAnimations];//停止动画

即可。
0 0