【问题标题】:How to rotate an image using touch如何使用触摸旋转图像
【发布时间】:2011-01-17 16:21:53
【问题描述】:

谁能告诉我如何根据用户给出的触摸旋转视图....

我的意思是我想做出类似旧电话的外观(按下并旋转拨号...)...

我非常了解如何旋转,但根据这种情况无法旋转.....

【问题讨论】:

标签: iphone


【解决方案1】:

你需要一个只有表盘图像的视图。

This view has a center C(x,y)
First, the view will be touched at coordinate T0(x,y)

if the x and y is within the circle do the tracking:
    Then the finger will move to coordinate Tn(x,y) 
    Find the angle made up by Tn(x,y) C(x,y) T0(x,y)  //(See below for a reference)
    and do the rotation using that angle as you already know ;)
else
   do nothing since the touch is not in the dial 

参考:How to calculate an angle from three points

【讨论】:

    【解决方案2】:

    计算开始触摸与表盘中心 (atan2f(y - yc, x - xc)) 之间的角度,并将其用作确定每个后续触摸事件所需的旋转的基础角度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-08
      • 2012-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多