如何使用触摸旋转图像

时间:2011-01-17 08:02:32

标签: iphone

任何人都可以告诉我,如何根据用户给出的触摸旋转视图....

我的意思是我想像旧电话那样做出类似的外观(按下并旋转拨打......)...... alt text

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

2 个答案:

答案 0 :(得分:5)

您需要一个仅包含刻度盘图像的视图。

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

答案 1 :(得分:3)

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