0
我想“检测”旋转 - 不跟踪它。我需要通过M_PI/8
顺时针或逆时针处理姿势旋转,然后旋转我的图像M_PI_2
或-M_PI_2
。如何使用UIRotationGestureRecognizer延迟旋转?
是否有可能使用UIRotationGestureRecognizer
?
我想“检测”旋转 - 不跟踪它。我需要通过M_PI/8
顺时针或逆时针处理姿势旋转,然后旋转我的图像M_PI_2
或-M_PI_2
。如何使用UIRotationGestureRecognizer延迟旋转?
是否有可能使用UIRotationGestureRecognizer
?
此代码的工作,因为我需要:
- (IBAction)rorationDid:(UIRotationGestureRecognizer *)recognizer
{
static CGFloat angle = 0;
if (recognizer.state == UIGestureRecognizerStateBegan)
angle = recognizer.rotation;
if (recognizer.state != UIGestureRecognizerStateEnded)
return;
float rotation = 0;
if (angle - recognizer.rotation > M_PI/8)
rotation = -M_PI_2;
if (angle - recognizer.rotation < -M_PI/8)
rotation = M_PI_2;
if (rotation != 0.0)
{
// Let's do rotation
}
}
UPDATE:
此代码:static CGFloat angle = 0;
真的应该是一个@property
不static
。