Shabeer Ali Shabeer Ali - 29 days ago 14
iOS Question

Rotation gesture for UIImageView

I have implemented a rotation gesture for

UIImageView
.

Here is the Code that I implemented:

- (IBAction)rotaehandler:(UIRotationGestureRecognizer *)sender
{
sender.view.transform = CGAffineTransformRotate(sender.view.transform, sender.rotation);
}


I connected
UIRotationGestureRecognizer
to
UIImageView
.
It works but, How can i rotate image form its center.

Answer
CGFloat initialRotation = atan2f(sender.view.transform.b-somefloat, sender.view.transform.a-somefloat);

 CGFloat newRotation = initialRotation + sender.rotation;

 sender.view.transform = CGAffineTransformMakeRotation(newRotation);

try above code

Comments