多次旋转图像并停止在所需的程度?

我已经尝试了各种方法,并不知道如何实现这一点。我在互联网上search了很多,但无法弄清楚。

我有一个ImageView (一个旋转的轮子),我想旋转360度10次(这只是给用户快速转动的感觉),然后我想要旋转它的特定值说90度(但可能会有所不同)。

在这个animation完成后,我想把ImageView带回到初始位置。

我如何做到这一点? 提前致谢。

以及我发现如何做到这一点。 我用下面的方法360度旋转10次,然后旋转一定的程度。

 -(void)rotate:(int)degreeToRotate { CGFloat radians = (M_PI/180) * degreeToRotate; [UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations: ^{ //configuring to rotate 360 degree 10 times CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ]; rotationAnimation.cumulative = YES; rotationAnimation.repeatCount = 10; [_scoreImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; } completion:^(BOOL finished) { //rotate by particular degree [ UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ // -radians, to ensure clockwise rotation self.scoreImageView.transform = CGAffineTransformMakeRotation(-radians); } completion:^(BOOL finished) { //method call to reset image original position [self performSelector:@selector(resetPosition) withObject:nil afterDelay:3]; }]; }]; } 

下面的方法用于将图像重置为原始位置。

 -(void)resetPosition { [UIView animateWithDuration:0.2 animations:^() { self.scoreImageView.transform = CGAffineTransformIdentity; }]; }