我有以下内容:
CGPoint pos //center of an image
CGPoint target //a point, somewhere in the coordinate system
float rotation //the current rotation of the image to the x-axis, clockwise, so "right" would be 90°
现在我希望图像围绕它的中心点(pos)旋转,以便它直接朝向目标点。
我的想法是:计算x轴对应的角度,减去旋转,然后旋转。
两件事情:
1.)我无法计算角度。(是的,我知道这一切都在 rad...)
2.) 什么最适合旋转?
- CGAffine变换?但是我需要一个 imageView
- 或者:保存上下文、将原点设置为图像中心、旋转上下文、绘制图像、恢复上下文?更复杂,但不需要图像视图......