如何连续旋转ios中的圆形图像?

iSu*_*esh 5 iphone ios

我有2个按钮开始和停止.如果我单击开始按钮,它会在我单击停止按钮时启动它的旋转,它会在单击停止按钮时停在确切位置.

再次点击开始按钮,它开始从前一状态开始旋转.

我是如何实现这一目标的?

在开始我写这个代码

CABasicAnimation *rotation=[CABasicAnimationanimationWithKeyPath:@"transform.rotation"];
rotation.fromValue=[NSNumber numberWithFloat:0];
rotation.toValue=[NSNumber numberWithFloat:((360*M_PI)/180)];
rotation.duration=2;
rotation.repeatCounts=INFINITY;
[image.layer addAnimation:rotation forKey:@"Spin"];
Run Code Online (Sandbox Code Playgroud)