Search code examples
uiviewtranslationrotationcgaffinetransform

Use PanGestureRecognizer translationInView to track touch location


How would i use a PanGestureRecognizer's translationInView which returns a CGPoint, to track the user touch location so that i can rotate an image so that the point where the user touches stays under the finger?

I can use CGAffineTransformRotate to do the rotation but it expects a rotation angle in radians. Currently i am using M_PI/20;

Thanks


Solution

  • add this to your code:

    #define degreesToRadians(degrees) (M_PI * degrees / 180.0)
    #define radiansToDegrees(radians) (radians * 180 / M_PI)