【发布时间】:2011-03-29 06:08:20
【问题描述】:
我想用一根手指触摸中心点旋转下面的图像...
当我使用触摸旋转图像时,我想用标签显示图像的值。
我已经完成了图像旋转,但问题是如何根据旋转设置图像的值。
旋转的角度增加了,所以我不能设置这个值。
谁能帮帮我?
代码如下
float fromAngle = atan2(firstLoc.y-imageView.center.y,
firstLoc.x-imageView.center.x);
NSLog(@"From angle:%f",fromAngle);
float toAngle = atan2( currentLoc.y-imageView.center.y,
currentLoc.x-imageView.center.x);
NSLog(@"to Angle:%f",toAngle);
// So the angle to rotate to is relative to our current angle and the
// angle through which our finger moved (to-from)
float newAngle =angle+(toAngle-fromAngle);
NSLog(@"new angle:%.2f",newAngle);
CGAffineTransform cgaRotate = CGAffineTransformMakeRotation(newAngle);
imageView.transform=cgaRotate;
angle = newAngle;
谁能帮帮我?
【问题讨论】:
-
“图像的价值”是什么意思?
-
我的图像中显示了从 0 到 50 的值。所以当我旋转图像时,特定值应该显示在标签中。