在我的应用程序中,我使用 SMRotatory 轮进行旋转。它作为旋转工作正常。
但我想检测旋转是顺时针还是逆时针?
//My code is as follow:
- (BOOL)continueTrackingWithTouch:(UITouch*)touch withEvent:(UIEvent*)event
{
CGFloat radians = atan2f(container.transform.b, container.transform.a);
// NSLog(@"rad is %f", radians);
CGPoint pt = [touch locationInView:self];
float dx = pt.x - container.center.x;
float dy = pt.y - container.center.y;
float ang = atan2(dy,dx);
float angleDifference = deltaAngle - ang;
// NSLog(@"%f",angleDifference);
if (angleDifference>=0) {
//NSLog(@"positive");
[[NSUserDefaults standardUserDefaults]setValue:@"positive" forKey:@"CheckValue"];
}
else
{
// NSLog(@"negative");
[[NSUserDefaults standardUserDefaults]setValue:@"negative" forKey:@"CheckValue"];
}
container.transform = CGAffineTransformRotate(startTransform, -angleDifference);
bg.transform=CGAffineTransformRotate(startTransform, -angleDifference);
return YES;
}