我正在使用这个示例代码RotationPie。它是一个轮子,我只想在我的项目中向一个方向移动或旋转它。我想提出不同的选项,用户将不得不选择其中之一。我希望轮子只向一个方向旋转。我认为我必须在类 CDCircleGestureRecognizer 中更改此方法中的某些内容,但我不知道是什么。
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
if ([self state] == UIGestureRecognizerStatePossible) {
[self setState:UIGestureRecognizerStateBegan];
} else {
[self setState:UIGestureRecognizerStateChanged];
}
// We can look at any touch object since we know we
// have only 1. If there were more than 1 then
// touchesBegan:withEvent: would have failed the recognizer.
UITouch *touch = [touches anyObject];
// To rotate with one finger, we simulate a second finger.
// The second figure is on the opposite side of the virtual
// circle that represents the rotation gesture.
CDCircle *view = (CDCircle *) [self view];
CGPoint center = CGPointMake(CGRectGetMidX([view bounds]), CGRectGetMidY([view bounds]));
CGPoint currentTouchPoint = [touch locationInView:view];
CGPoint previousTouchPoint = [touch previousLocationInView:view];
previousTouchDate = [NSDate date];
CGFloat angleInRadians = atan2f(currentTouchPoint.y - center.y, currentTouchPoint.x - center.x) - atan2f(previousTouchPoint.y - center.y, previousTouchPoint.x - center.x);
CGFloat one = atan2f(currentTouchPoint.y - center.y, currentTouchPoint.x - center.x);
CGFloat two =atan2f(previousTouchPoint.y - center.y, previousTouchPoint.x - center.x);
currentTransformAngle = atan2f(view.transform.b, view.transform.a);
[self setRotation:angleInRadians];