[Solved] how to rotate an image in different direction using single button?


try this,

here yourImage is the image view which is to be rotated

- (IBAction)rotateImage:(UIButton *)sender // your button action method
{
    if (!sender.selected)
    {
        [sender setSelected:YES];
        [UIView animateKeyframesWithDuration:2.0
                                       delay:0.0
                                     options:UIViewKeyframeAnimationOptionCalculationModeLinear
                                  animations:^{
                                      [UIView addKeyframeWithRelativeStartTime:0.0
                                                              relativeDuration:1/3.0
                                                                    animations:^{
                                                                        yourImage.transform = CGAffineTransformMakeRotation(2.0 * M_PI / 3.0);
                                                                    }];
                                      [UIView addKeyframeWithRelativeStartTime:1/3.0
                                                              relativeDuration:1/3.0
                                                                    animations:^{
                                                                        yourImage.transform = CGAffineTransformMakeRotation(4.0 * M_PI / 3.0);
                                                                    }];
                                      [UIView addKeyframeWithRelativeStartTime:2/3.0
                                                              relativeDuration:1/3.0
                                                                    animations:^{
                                                                        yourImage.transform = CGAffineTransformMakeRotation(0);
                                                                    }];

                                  }
                                  completion:^(BOOL finished) {

                                  }];
        }
    else
    {
        [sender setSelected:NO];

        [UIView animateKeyframesWithDuration:2.0
                                       delay:0.0
                                     options:UIViewKeyframeAnimationOptionCalculationModeLinear
                                  animations:^{
                                      [UIView addKeyframeWithRelativeStartTime:0.0
                                                              relativeDuration:1/3.0
                                                                    animations:^{
                                                                        yourImage.transform = CGAffineTransformMakeRotation(4.0 * M_PI / 3.0);
                                                                    }];
                                      [UIView addKeyframeWithRelativeStartTime:1/3.0
                                                              relativeDuration:1/3.0
                                                                    animations:^{
                                                                        yourImage.transform = CGAffineTransformMakeRotation(2.0 * M_PI / 3.0);
                                                                    }];
                                      [UIView addKeyframeWithRelativeStartTime:2/3.0
                                                              relativeDuration:1/3.0
                                                                    animations:^{
                                                                        yourImage.transform = CGAffineTransformMakeRotation(0);
                                                                    }];

                                  }
                                  completion:^(BOOL finished) {

                                  }];
    }
}

solved how to rotate an image in different direction using single button?