Uiview 使用PangestureRecognitor TranslationView跟踪触摸位置

Uiview 使用PangestureRecognitor TranslationView跟踪触摸位置,uiview,translation,rotation,cgaffinetransform,Uiview,Translation,Rotation,Cgaffinetransform,如何使用PangestureRecognitor的TranslationView(返回CGPoint)来跟踪用户触摸位置,以便旋转图像,从而用户触摸的点保持在手指下方 我可以使用cGraffineTransformRotate进行旋转,但它需要以弧度为单位的旋转角度。目前我使用的是M_PI/20 谢谢将此添加到您的代码中: #define degreesToRadians(degrees) (M_PI * degrees / 180.0) #define radiansToDegrees(rad

如何使用PangestureRecognitor的
TranslationView
(返回
CGPoint
)来跟踪用户触摸位置,以便旋转图像,从而用户触摸的点保持在手指下方

我可以使用
cGraffineTransformRotate
进行旋转,但它需要以弧度为单位的旋转角度。目前我使用的是
M_PI/20

谢谢

将此添加到您的代码中:

#define degreesToRadians(degrees) (M_PI * degrees / 180.0)
#define radiansToDegrees(radians) (radians * 180 / M_PI)
苹果公司提供以下转换功能:

func GLKMathDegreesToRadians(_ degrees: Float) -> Float
func GLKMathRadiansToDegrees(_ radians: Float) -> Float