diff --git a/SlideMenu/AppDelegate.m b/SlideMenu/AppDelegate.m index e48a2ea..8e84687 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..37b8d66 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 14808bd..bc5cad7 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 @@ -101,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) @@ -108,6 +119,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; @@ -232,9 +245,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; @@ -287,12 +300,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 @@ -467,7 +480,7 @@ static SlideNavigationController *singletonInstance; [UIView animateWithDuration:duration delay:0 - options:UIViewAnimationOptionCurveEaseOut + options:self.menuRevealAnimationOption animations:^{ CGRect rect = self.view.frame; CGFloat width = self.horizontalSize; @@ -490,7 +503,7 @@ static SlideNavigationController *singletonInstance; [UIView animateWithDuration:duration delay:0 - options:UIViewAnimationOptionCurveEaseOut + options:self.menuRevealAnimationOption animations:^{ CGRect rect = self.view.frame; rect.origin.x = 0; @@ -647,6 +660,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