【问题标题】:Rotate image to point将图像旋转到点
【发布时间】:2011-11-28 23:58:40
【问题描述】:

我有以下几点:

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
  • 或者:保存上下文、将原点设置为图像中心、旋转上下文、绘制图像、恢复上下文?更复杂,但不需要 imageview...

【问题讨论】:

    标签: objective-c ios4 image-rotation


    【解决方案1】:

    在 CALayer 上绘制它,然后随意移动图层。

    【讨论】:

    • 好的,我做到了...你能帮我解决一下 CALayer 的问题吗?我有我的图像,需要将其旋转 x rad....
    猜你喜欢
    • 1970-01-01
    • 2012-05-14
    • 1970-01-01
    • 2011-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-30
    • 1970-01-01
    相关资源
    最近更新 更多