diff --git a/SlideMenu/Helper Classes/HomeViewController.h b/SlideMenu/Helper Classes/HomeViewController.h index 0afd2cb..c0a1ef1 100755 --- a/SlideMenu/Helper Classes/HomeViewController.h +++ b/SlideMenu/Helper Classes/HomeViewController.h @@ -11,4 +11,6 @@ @interface HomeViewController : UIViewController +- (IBAction)bounceMenu:(id)sender; + @end diff --git a/SlideMenu/Helper Classes/HomeViewController.m b/SlideMenu/Helper Classes/HomeViewController.m index 46d7fa7..97fbd71 100755 --- a/SlideMenu/Helper Classes/HomeViewController.m +++ b/SlideMenu/Helper Classes/HomeViewController.m @@ -27,4 +27,15 @@ return YES; } +#pragma mark - IBActions - + +- (IBAction)bounceMenu:(id)sender +{ + static Menu menu = MenuLeft; + + [[SlideNavigationController sharedInstance] bounceMenu:menu withCompletion:nil]; + + menu = (menu == MenuLeft) ? MenuRight : MenuLeft; +} + @end diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index 9b4bd49..8471996 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -54,6 +54,7 @@ typedef enum{ + (SlideNavigationController *)sharedInstance; - (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion; +- (void)bounceMenu:(Menu)menu withCompletion:(void (^)())completion; - (void)openMenu:(Menu)menu withCompletion:(void (^)())completion; - (void)closeMenuWithCompletion:(void (^)())completion; - (void)toggleLeftMenu; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index b355a09..48fa3be 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -136,19 +136,41 @@ static SlideNavigationController *singletonInstance; self.view.layer.shadowOpacity = MENU_SHADOW_OPACITY; } -- (void)updateMenuFrameAndTransformAccordingToOrientation -{ - // Animate rotatation when menu is open and device rotates - CGAffineTransform transform = self.view.transform; - self.leftMenu.view.transform = transform; - self.rightMenu.view.transform = transform; - - self.leftMenu.view.frame = [self initialRectForMenu]; - self.rightMenu.view.frame = [self initialRectForMenu]; -} - #pragma mark - Public Methods - +- (void)bounceMenu:(Menu)menu withCompletion:(void (^)())completion +{ + [self prepareMenuForReveal:menu forcePrepare:YES]; + NSInteger movementDirection = (menu == MenuLeft) ? 1 : -1; + + [UIView animateWithDuration:.16 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ + [self moveHorizontallyToLocation:30*movementDirection]; + } completion:^(BOOL finished){ + [UIView animateWithDuration:.1 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ + [self moveHorizontallyToLocation:0]; + } completion:^(BOOL finished){ + [UIView animateWithDuration:.12 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ + [self moveHorizontallyToLocation:16*movementDirection]; + } completion:^(BOOL finished){ + [UIView animateWithDuration:.08 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ + [self moveHorizontallyToLocation:0]; + } completion:^(BOOL finished){ + [UIView animateWithDuration:.08 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ + [self moveHorizontallyToLocation:6*movementDirection]; + } completion:^(BOOL finished){ + [UIView animateWithDuration:.06 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ + [self moveHorizontallyToLocation:0]; + } completion:^(BOOL finished){ + if (completion) + completion(); + }]; + }]; + }]; + }]; + }]; + }]; +} + - (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion { if (self.avoidSwitchingToSameClassViewController && [self.topViewController isKindOfClass:viewController.class]) @@ -262,6 +284,17 @@ static SlideNavigationController *singletonInstance; #pragma mark - Private Methods - +- (void)updateMenuFrameAndTransformAccordingToOrientation +{ + // Animate rotatation when menu is open and device rotates + CGAffineTransform transform = self.view.transform; + self.leftMenu.view.transform = transform; + self.rightMenu.view.transform = transform; + + self.leftMenu.view.frame = [self initialRectForMenu]; + self.rightMenu.view.frame = [self initialRectForMenu]; +} + - (void)enableTapGestureToCloseMenu:(BOOL)enable { if (enable) diff --git a/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard b/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard index 2ac4a4c..c0941cc 100755 --- a/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard +++ b/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard @@ -94,9 +94,9 @@