From 4c66f6c25c4b35425690acea445f02d46df19c10 Mon Sep 17 00:00:00 2001 From: Aryan Date: Fri, 28 Nov 2014 15:34:55 -0800 Subject: [PATCH 1/4] Allow configuring animation duration/option --- SlideMenu/AppDelegate.m | 1 + .../Helper Classes/RightMenuViewController.m | 8 ++++++++ SlideMenu/Source/SlideNavigationController.h | 2 ++ SlideMenu/Source/SlideNavigationController.m | 15 +++++++++------ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/SlideMenu/AppDelegate.m b/SlideMenu/AppDelegate.m index e48a2ea..ea8e3a3 100644 --- a/SlideMenu/AppDelegate.m +++ b/SlideMenu/AppDelegate.m @@ -23,6 +23,7 @@ [SlideNavigationController sharedInstance].rightMenu = rightMenu; [SlideNavigationController sharedInstance].leftMenu = leftMenu; + [SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18; // Creating a custom bar button for right menu UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; diff --git a/SlideMenu/Helper Classes/RightMenuViewController.m b/SlideMenu/Helper Classes/RightMenuViewController.m index 96a7767..1eddee5 100644 --- a/SlideMenu/Helper Classes/RightMenuViewController.m +++ b/SlideMenu/Helper Classes/RightMenuViewController.m @@ -80,31 +80,38 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { id revealAnimator; + CGFloat animationDuration = 0; switch (indexPath.row) { case 0: revealAnimator = nil; + animationDuration = .19; break; case 1: revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init]; + animationDuration = .19; break; case 2: revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init]; + animationDuration = .18; break; case 3: revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.8 fadeColor:[UIColor blackColor] andSlideMovement:100]; + animationDuration = .19; break; case 4: revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init]; + animationDuration = .22; break; case 5: revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] initWithMaximumFadeAlpha:.6 fadeColor:[UIColor blackColor] andMinimumScale:.8]; + animationDuration = .22; break; default: @@ -112,6 +119,7 @@ } [[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{ + [SlideNavigationController sharedInstance].menuRevealAnimationDuration = animationDuration; [SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator; }]; } diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index bc54bf1..b64701b 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -58,6 +58,8 @@ extern NSString *const SlideNavigationControllerDidReveal; @property (nonatomic, assign) CGFloat portraitSlideOffset; @property (nonatomic, assign) CGFloat landscapeSlideOffset; @property (nonatomic, assign) CGFloat panGestureSideOffset; +@property (nonatomic, assign) CGFloat menuRevealAnimationDuration; +@property (nonatomic, assign) UIViewAnimationOptions menuRevealAnimationOption; @property (nonatomic, strong) id menuRevealAnimator; + (SlideNavigationController *)sharedInstance; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 091ea91..38a9810 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -48,6 +48,7 @@ NSString * const SlideNavigationControllerDidClose = @"SlideNavigationController NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal"; #define MENU_SLIDE_ANIMATION_DURATION .3 +#define MENU_SLIDE_ANIMATION_OPTION UIViewAnimationOptionCurveEaseOut #define MENU_QUICK_SLIDE_ANIMATION_DURATION .18 #define MENU_IMAGE @"menu-button" #define MENU_SHADOW_RADIUS 10 @@ -108,6 +109,8 @@ static SlideNavigationController *singletonInstance; singletonInstance = self; + self.menuRevealAnimationDuration = MENU_SLIDE_ANIMATION_DURATION; + self.menuRevealAnimationOption = MENU_SLIDE_ANIMATION_OPTION; self.landscapeSlideOffset = MENU_DEFAULT_SLIDE_OFFSET; self.portraitSlideOffset = MENU_DEFAULT_SLIDE_OFFSET; self.panGestureSideOffset = 0; @@ -230,9 +233,9 @@ static SlideNavigationController *singletonInstance; { if (slideOutAnimation) { - [UIView animateWithDuration:(slideOutAnimation) ? MENU_SLIDE_ANIMATION_DURATION : 0 + [UIView animateWithDuration:(slideOutAnimation) ? self.menuRevealAnimationDuration : 0 delay:0 - options:UIViewAnimationOptionCurveEaseOut + options:self.menuRevealAnimationOption animations:^{ CGFloat width = self.horizontalSize; CGFloat moveLocation = (self.horizontalLocation> 0) ? width : -1*width; @@ -285,12 +288,12 @@ static SlideNavigationController *singletonInstance; - (void)closeMenuWithCompletion:(void (^)())completion { - [self closeMenuWithDuration:MENU_SLIDE_ANIMATION_DURATION andCompletion:completion]; + [self closeMenuWithDuration:self.menuRevealAnimationDuration andCompletion:completion]; } - (void)openMenu:(Menu)menu withCompletion:(void (^)())completion { - [self openMenu:menu withDuration:MENU_SLIDE_ANIMATION_DURATION andCompletion:completion]; + [self openMenu:menu withDuration:self.menuRevealAnimationDuration andCompletion:completion]; } - (void)toggleLeftMenu @@ -465,7 +468,7 @@ static SlideNavigationController *singletonInstance; [UIView animateWithDuration:duration delay:0 - options:UIViewAnimationOptionCurveEaseOut + options:self.menuRevealAnimationOption animations:^{ CGRect rect = self.view.frame; CGFloat width = self.horizontalSize; @@ -488,7 +491,7 @@ static SlideNavigationController *singletonInstance; [UIView animateWithDuration:duration delay:0 - options:UIViewAnimationOptionCurveEaseOut + options:self.menuRevealAnimationOption animations:^{ CGRect rect = self.view.frame; rect.origin.x = 0; From 9d38ca4c769a67a87697417c6b7b4bbf2f5a3727 Mon Sep 17 00:00:00 2001 From: Aryan Date: Sun, 25 Jan 2015 08:48:54 -0800 Subject: [PATCH 2/4] Fixed #103 add initWithNavigationBarClass to slide menu --- SlideMenu/Source/SlideNavigationController.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 38a9810..a504858 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -102,6 +102,16 @@ static SlideNavigationController *singletonInstance; return self; } +- (id)initWithNavigationBarClass:(Class)navigationBarClass toolbarClass:(Class)toolbarClass +{ + if (self = [super initWithNavigationBarClass:navigationBarClass toolbarClass:toolbarClass]) + { + [self setup]; + } + + return self; +} + - (void)setup { if (singletonInstance) @@ -109,8 +119,8 @@ static SlideNavigationController *singletonInstance; singletonInstance = self; - self.menuRevealAnimationDuration = MENU_SLIDE_ANIMATION_DURATION; - self.menuRevealAnimationOption = MENU_SLIDE_ANIMATION_OPTION; + self.menuRevealAnimationDuration = MENU_SLIDE_ANIMATION_DURATION; + self.menuRevealAnimationOption = MENU_SLIDE_ANIMATION_OPTION; self.landscapeSlideOffset = MENU_DEFAULT_SLIDE_OFFSET; self.portraitSlideOffset = MENU_DEFAULT_SLIDE_OFFSET; self.panGestureSideOffset = 0; From 2786733c82385ef07539b2c1fcd569bfe3b667b9 Mon Sep 17 00:00:00 2001 From: Aryan Date: Sun, 25 Jan 2015 08:49:13 -0800 Subject: [PATCH 3/4] Code formatting --- SlideMenu/AppDelegate.m | 2 +- .../Helper Classes/RightMenuViewController.m | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SlideMenu/AppDelegate.m b/SlideMenu/AppDelegate.m index ea8e3a3..8e84687 100644 --- a/SlideMenu/AppDelegate.m +++ b/SlideMenu/AppDelegate.m @@ -23,7 +23,7 @@ [SlideNavigationController sharedInstance].rightMenu = rightMenu; [SlideNavigationController sharedInstance].leftMenu = leftMenu; - [SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18; + [SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18; // Creating a custom bar button for right menu UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; diff --git a/SlideMenu/Helper Classes/RightMenuViewController.m b/SlideMenu/Helper Classes/RightMenuViewController.m index 1eddee5..37b8d66 100644 --- a/SlideMenu/Helper Classes/RightMenuViewController.m +++ b/SlideMenu/Helper Classes/RightMenuViewController.m @@ -80,38 +80,38 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { id revealAnimator; - CGFloat animationDuration = 0; + CGFloat animationDuration = 0; switch (indexPath.row) { case 0: revealAnimator = nil; - animationDuration = .19; + animationDuration = .19; break; case 1: revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init]; - animationDuration = .19; + animationDuration = .19; break; case 2: revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init]; - animationDuration = .18; + animationDuration = .18; break; case 3: revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.8 fadeColor:[UIColor blackColor] andSlideMovement:100]; - animationDuration = .19; + animationDuration = .19; break; case 4: revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init]; - animationDuration = .22; + animationDuration = .22; break; case 5: revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] initWithMaximumFadeAlpha:.6 fadeColor:[UIColor blackColor] andMinimumScale:.8]; - animationDuration = .22; + animationDuration = .22; break; default: @@ -119,7 +119,7 @@ } [[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{ - [SlideNavigationController sharedInstance].menuRevealAnimationDuration = animationDuration; + [SlideNavigationController sharedInstance].menuRevealAnimationDuration = animationDuration; [SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator; }]; } From eb2de83daf41cdba9b5e683067d66a4785d84466 Mon Sep 17 00:00:00 2001 From: Aryan Date: Sun, 25 Jan 2015 08:50:52 -0800 Subject: [PATCH 4/4] #79 and #90 Allow simultaneous gestures to be detected by the menu --- SlideMenu/Source/SlideNavigationController.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index a504858..976c098 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -658,6 +658,13 @@ static SlideNavigationController *singletonInstance; [[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:userInfo]; } +#pragma mark - UIGestureRecognizerDelegate Methods - + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + return YES; +} + #pragma mark - UINavigationControllerDelegate Methods - - (void)navigationController:(UINavigationController *)navigationController