Faire tourner l'image plusieurs fois et s'arrêter au degré désiré?

J'avais essayé de diverses methods et ne pouvais pas comprendre comment réaliser ceci. J'ai cherché beaucoup sur Internet mais ne peux pas comprendre dehors.

J'ai un ImageView (une roue qui tourne), je veux le faire pivoter de 360 ​​degrés pendant 10 fois (ceci est juste pour donner à l'user la sensation de tourner rapidement la roue), puis je veux le faire pivoter par une valeur particulière de 90 degrés ( mais il pourrait être variable).

Une fois cette animation terminée, je veux ramener ImageView à la position initiale.

comment puis-je y parvenir? Merci d'avance.

Eh bien, j'ai trouvé comment faire cela. J'ai utilisé la méthode ci-dessous pour faire pivoter de 360 ​​degrés pour 10 fois, puis tourner d'un degré particulier.

 -(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]; }]; }]; } 

La méthode ci-dessous est utilisée pour réinitialiser l'image à la position d'origine.

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