Is it possible to rotate a view using a UIPanGestureRecognizer? I would like similar functionality to the rotation gesture but with only one finger.
Thanks.
Is it possible to rotate a view using a UIPanGestureRecognizer? I would like similar functionality to the rotation gesture but with only one finger.
Thanks.
Sure. But you'll need to do your own rotation math, of course. If you have a "center point" of rotation for the view already, that's especially useful, as you can track the angle of the touch input relative to that center, and apply the transform
property of the view (or whatever) when it updates.
Check out CGAffineTransformMakeRotation
.
This website should help.
http://chris-software.com/index.php/2009/04/26/animations-and-transformations/
From site:
# M_PI * 0.00 = 0° (original condition)
# M_PI * 0.25 = 45°
# M_PI * 0.50 = 90°
# M_PI * 0.75 = 135°
# M_PI * 1.00 = 180°
# M_PI * -0.75 = 225°
# M_PI * -0.50 = 270°
# M_PI * -0.25 = 315°