Question: im looking to Rotate a UIImageView, and i found some helpfull code

```
- (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:    (CGFloat)rotations repeat:(float)repeat;
{
    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
    rotationAnimation.duration = duration;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = repeat;

    [view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

}

```

The issue is that the image flips back when the animation finishes, im looking to rotate it and keep it there. Would i need to flip the actual image or can i flip the ImageView. And how would i do that`?

Answer: 
Why not use a standard [`UIView` animation](https://developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW131)?
If you really need the `repeatCount`, then I suggest you use the old style:

```
[UIView beginAnimations]
[UIView setAnimationRepeatCount:repeatCount];
[UIView setAnimationDuration:duration];
yourView.transform = CGAffineTransformMakeRotation(degrees * M_PI);
[UIView commitAnimations];

```

Otherwise, you can use the much preferred new style:

```
[UIView animateWithDuration:duration animations:^{
    yourView.transform = CGAffineTransformMakeRotation(angle);
} completion:^(BOOL finished) {
    // your completion code here
}]

```

If you need other options like autoreverse, allow user interaction or repeating use `[UIView animateWithDuration:delay:options:animations:completion:];`
I prefer to cover all my bases with CoreAnimation. Set the final value before the animation, set the fill mode, and set do not remove. 

```
- (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:            (CGFloat)rotations repeat:(float)repeat;
{
    NSString * animationKeyPath = @"transform.rotation.z";
    CGFloat finalRotation = M_PI * 2.0f * rotations;
    [view.layer setValue:@(finalRotation) forKey:animationKeyPath];

    CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:animationKeyPath];
    rotationAnimation.fromValue = @0.0f;
    rotationAnimation.toValue = @(finalRotation);
    rotationAnimation.fillMode = kCAFillModeBoth;
    rotationAnimation.removedOnCompletion = NO;
    rotationAnimation.duration = duration;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = repeat;

    [view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}

```