title: Imageview rotation issues in iOS
body: <p>I have next task: on button click image have to rotate to 90 degrees.</p>
  
  <p>My code is:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;QuartzCore/QuartzCore.h&gt;
  @interface ViewController : UIViewController
  @property (strong, nonatomic) IBOutlet UIImageView *vector;
  @end
  </code></pre>
  
  <p>=========</p>
  
  <pre><code>@interface ViewController ()
  
  @end
  
  @implementation ViewController
  @synthesize vector;
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  }
  - (IBAction)rotateOn:(id)sender {
      [self rotateImage:self.vector duration:2
                  curve:UIViewAnimationCurveEaseIn degrees:M_PI/2];
  }
  
  - (void)rotateImage:(UIImageView *)image duration:(NSTimeInterval)duration
                curve:(int)curve degrees:(CGFloat)degrees
  {
      // Setup the animation
      [UIView beginAnimations:NULL context:NULL];
      [UIView setAnimationDuration:duration];
      [UIView setAnimationCurve:curve];
      [UIView setAnimationBeginsFromCurrentState:YES];
      [image.layer setAnchorPoint:CGPointMake(0.5,0.5)];
      CGAffineTransform transform =
      CGAffineTransformMakeRotation(degrees);
      image.transform = transform;
      [UIView commitAnimations];
  }
  </code></pre>
  
  <p><br><br><br>
  Before click on the button I have this<br><br>
  <img src="https://i.stack.imgur.com/ECTHx.png" alt="Before Click">
  <br><br><br>
  After click this<br><br>
  <img src="https://i.stack.imgur.com/RVN9n.png" alt="After Click"></p>
  
  <p>You can see that image rotate to 90 degrees. But it moved down from start center point.
  Also if I click button again nothing happens.</p>