Created
May 10, 2013 00:36
-
-
Save kenshin03/5551666 to your computer and use it in GitHub Desktop.
PSHMenuGestureRecognizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { | |
UITouch * touch = [touches anyObject]; | |
CGPoint touchPoint = [touch locationInView:self.view]; | |
UIView * menuView = [self.view viewWithTag:kPSHMenuViewControllerMenuButtonViewTag]; | |
if (CGRectContainsPoint(menuView.frame, touchPoint)){ | |
[self setState:UIGestureRecognizerStateBegan]; | |
self.menuViewBeingMoved = menuView; | |
}else{ | |
[self setState:UIGestureRecognizerStateFailed]; | |
self.menuViewBeingMoved = nil; | |
} | |
} | |
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { | |
UITouch * touch = [touches anyObject]; | |
CGPoint touchPoint = [touch locationInView:self.view]; | |
CGRect menuViewFrame = self.menuViewBeingMoved.frame; | |
menuViewFrame.origin = CGPointMake(touchPoint.x-44.0f, touchPoint.y-44.0f); | |
[UIView animateWithDuration:0.1 delay:0.1 options:UIViewAnimationOptionCurveEaseIn animations:^{ | |
self.menuViewBeingMoved.frame = menuViewFrame; | |
} completion:^(BOOL finished) { | |
// none | |
}]; | |
[self setState:UIGestureRecognizerStateChanged]; | |
} | |
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { | |
[self setState:UIGestureRecognizerStateEnded]; | |
} | |
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { | |
[self setState:UIGestureRecognizerStateEnded]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment