Search code examples
iphonerotationcgaffinetransform

Image rotates only once


I walked over other same question but it didn't help. I have an image that should rotate every doubleTap by 90 degrees

This is the rotation function

-(void) rotateImageWithAngle:(float)angle1
{

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.2];
    [UIView setAnimationBeginsFromCurrentState:YES];

    CGAffineTransform transform;
    transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(angle1));
    self.transform = transform;

    [UIView commitAnimations];   
}

angel1 is always 90. The problem is that it rotates only once, every additional doubleTap goes to the function but does nothing.

Thanks


Solution

  • You're applying the same transform every time. You should change the angle by 90 degrees with each double tap.