Search code examples
iphoneobjective-cuiviewcgaffinetransform

UIView Rotation


Hello All I want to rotate UIView on single finger touch and it still rotate untill finger moves on screen of iPhone and it stops rotation when I stop the finger moving or remove it from screen.

Thanks in Advance.


Solution

  • Try similar code

    -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.2];
        CGAffineTransform rr=CGAffineTransformMakeRotation(5);
        yourView.transform=CGAffineTransformConcat(yourView.transform, rr);
        [UIView commitAnimations];
    }
    
    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        [self touchesBegan:touches withEvent:event];
    }