From 373be130806c3cf0ff2443fe9ebd63182390daf6 Mon Sep 17 00:00:00 2001 From: Aryan Ghassemi Date: Sun, 26 Jan 2014 12:28:45 -0800 Subject: [PATCH 1/6] - Added scale animation --- SlideMenu/Helper Classes/MenuViewController.m | 58 +++++++++- SlideMenu/Source/SlideNavigationController.h | 5 +- SlideMenu/Source/SlideNavigationController.m | 106 ++++++++++++------ .../en.lproj/MainStoryboard_iPhone.storyboard | 2 +- 4 files changed, 133 insertions(+), 38 deletions(-) diff --git a/SlideMenu/Helper Classes/MenuViewController.m b/SlideMenu/Helper Classes/MenuViewController.m index a7aac5b..7df7903 100755 --- a/SlideMenu/Helper Classes/MenuViewController.m +++ b/SlideMenu/Helper Classes/MenuViewController.m @@ -15,7 +15,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 15; + return 10; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath @@ -40,8 +40,28 @@ cell.textLabel.text = @"Sign Out"; break; - default: - cell.textLabel.text = @"Random Cell"; + case 4: + cell.textLabel.text = @"No Animation"; + break; + + case 5: + cell.textLabel.text = @"Slide Animation"; + break; + + case 6: + cell.textLabel.text = @"Fade Animation"; + break; + + case 7: + cell.textLabel.text = @"Slide And Fade Animation"; + break; + + case 8: + cell.textLabel.text = @"Scale Animation"; + break; + + case 9: + cell.textLabel.text = @"Scale And Fade Animation"; break; } @@ -54,6 +74,7 @@ bundle: nil]; UIViewController *vc ; + MenuRevealAnimation revealAnimation = MenuRevealAnimationNone; switch (indexPath.row) { @@ -74,11 +95,40 @@ return; break; + case 4: + revealAnimation = MenuRevealAnimationNone; + break; + + case 5: + revealAnimation = MenuRevealAnimationSlide; + break; + + case 6: + revealAnimation = MenuRevealAnimationFade; + break; + + case 7: + revealAnimation = MenuRevealAnimationSlideAndFade; + break; + + case 8: + revealAnimation = MenuRevealAnimationScale; + break; + + case 9: + revealAnimation = MenuRevealAnimationScaleAndFade; + break; + default: return; } - [[SlideNavigationController sharedInstance] switchToViewController:vc withCompletion:nil]; + if (vc) + [[SlideNavigationController sharedInstance] switchToViewController:vc withCompletion:nil]; + else + [[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{ + [SlideNavigationController sharedInstance].menuRevealAnimation = revealAnimation; + }]; } @end diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index 6c990bd..4775feb 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -43,7 +43,9 @@ typedef enum{ MenuRevealAnimationNone, MenuRevealAnimationFade, MenuRevealAnimationSlide, - MenuRevealAnimationSlideAndFade + MenuRevealAnimationSlideAndFade, + MenuRevealAnimationScale, + MenuRevealAnimationScaleAndFade }MenuRevealAnimation; @interface SlideNavigationController : UINavigationController @@ -60,6 +62,7 @@ typedef enum{ @property (nonatomic, assign) CGFloat menuRevealAnimationFadeMaximumAlpha; @property (nonatomic, strong) UIColor *menuRevealAnimationFadeColor; @property (nonatomic, assign) CGFloat menuRevealAnimationSlideMovement; +@property (nonatomic, assign) CGFloat menuRevealAnimationScaleMinScale; + (SlideNavigationController *)sharedInstance; - (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 180c04b..197188b 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -46,6 +46,7 @@ #define MENU_FAST_VELOCITY_FOR_SWIPE_FOLLOW_DIRECTION 1200 #define MENU_REVEAL_ANIMATION_DEFAULT_SLIDE_MOVEMENT 100 #define MENU_REVEAL_ANIMATION_DEFAULT_FADE_MAXIMUM_ALPHA .8 +#define MENU_REVEAL_ANIMATION_DEFAULT_SCALE_MINIMUM_SCALE .85 #define STATUS_BAR_HEIGHT 20 static SlideNavigationController *singletonInstance; @@ -90,6 +91,7 @@ static SlideNavigationController *singletonInstance; - (void)setup { self.menuRevealAnimationSlideMovement = MENU_REVEAL_ANIMATION_DEFAULT_SLIDE_MOVEMENT; + self.menuRevealAnimationScaleMinScale = MENU_REVEAL_ANIMATION_DEFAULT_SCALE_MINIMUM_SCALE; self.menuRevealAnimationFadeMaximumAlpha = MENU_REVEAL_ANIMATION_DEFAULT_FADE_MAXIMUM_ALPHA; self.menuRevealAnimation = MenuRevealAnimationSlideAndFade; self.landscapeSlideOffset = MENU_DEFAULT_SLIDE_OFFSET; @@ -106,6 +108,7 @@ static SlideNavigationController *singletonInstance; self.view.layer.rasterizationScale = [UIScreen mainScreen].scale; [self setEnableSwipeGesture:YES]; + [self updateMenuFrameAndTransformAccordingToOrientation]; } - (void)viewWillLayoutSubviews @@ -120,9 +123,6 @@ static SlideNavigationController *singletonInstance; { [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; - // Update rotation animation - [self updateMenuFrameAndTransformAccordingToOrientation]; - // Avoid an ugnly shadow in background while rotating self.view.layer.shadowOpacity = 0; } @@ -131,6 +131,9 @@ static SlideNavigationController *singletonInstance; { [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; + // Update rotation animation + [self updateMenuFrameAndTransformAccordingToOrientation]; + self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds].CGPath; // we set shadowOpacity to 0 in willRotateToInterfaceOrientation, after the rotation we want to add the shadow back @@ -139,17 +142,13 @@ static SlideNavigationController *singletonInstance; - (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; - CGRect rect = self.view.frame; - self.leftMenu.view.frame = rect; - self.rightMenu.view.frame = rect; - - // Move menus accordingly to avoid a weird animation during opening/closing menu after a rotation - [self updateMenuAnimation:MenuLeft]; - [self updateMenuAnimation:MenuRight]; + self.leftMenu.view.frame = [self initialRectForMenu]; + self.rightMenu.view.frame = [self initialRectForMenu]; } #pragma mark - Public Methods - @@ -386,14 +385,17 @@ static SlideNavigationController *singletonInstance; ? (self.horizontalLocation / self.maxXForDragging) : (self.horizontalLocation / self.minXForDragging); - if (self.menuRevealAnimation == MenuRevealAnimationFade || self.menuRevealAnimation == MenuRevealAnimationSlideAndFade) + if (self.menuRevealAnimation == MenuRevealAnimationFade || + self.menuRevealAnimation == MenuRevealAnimationSlideAndFade || + self.menuRevealAnimation == MenuRevealAnimationScaleAndFade) { self.menuRevealFadeAnimationView.frame = menuViewController.view.bounds; [menuViewController.view addSubview:self.menuRevealFadeAnimationView]; self.menuRevealFadeAnimationView.alpha = self.menuRevealAnimationFadeMaximumAlpha - (self.menuRevealAnimationFadeMaximumAlpha *progress); } - if (self.menuRevealAnimation == MenuRevealAnimationSlide || self.menuRevealAnimation == MenuRevealAnimationSlideAndFade) + if (self.menuRevealAnimation == MenuRevealAnimationSlide || + self.menuRevealAnimation == MenuRevealAnimationSlideAndFade) { NSInteger location = (menu == MenuLeft) ? (self.menuRevealAnimationSlideMovement * -1) + (self.menuRevealAnimationSlideMovement * progress) @@ -405,34 +407,56 @@ static SlideNavigationController *singletonInstance; if (menu == MenuRight) location = (location < 0) ? 0 : location; - CGRect rect = menuViewController.view.frame; - BOOL isIos7 = SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"); + CGRect rect = [self initialRectForMenu]; if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) { rect.origin.y = (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) ? location : location*-1; - - if (!isIos7) - { - // For some reasons in landscape belos the status bar is considered y=0, but in portrait it's considered y=20 - rect.origin.x = (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) ? 0 : STATUS_BAR_HEIGHT; - rect.size.width = self.view.frame.size.width-STATUS_BAR_HEIGHT; - } } else { rect.origin.x = (self.interfaceOrientation == UIInterfaceOrientationPortrait) ? location : location*-1; - - if (!isIos7) - { - // For some reasons in landscape belos the status bar is considered y=0, but in portrait it's considered y=20 - rect.origin.y = (self.interfaceOrientation == UIInterfaceOrientationPortrait) ? STATUS_BAR_HEIGHT : 0; - rect.size.height = self.view.frame.size.height-STATUS_BAR_HEIGHT; - } } menuViewController.view.frame = rect; } + + if (self.menuRevealAnimation == MenuRevealAnimationScale || + self.menuRevealAnimation == MenuRevealAnimationScaleAndFade) + { + CGFloat scale = MIN(1, (1-self.menuRevealAnimationScaleMinScale) *progress + self.menuRevealAnimationScaleMinScale); + menuViewController.view.transform = CGAffineTransformScale(self.view.transform, scale, scale); + } +} + +- (CGRect)initialRectForMenu +{ + CGRect rect = self.view.frame; + rect.origin.x = 0; + rect.origin.y = 0; + + BOOL isIos7 = SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"); + + if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) + { + if (!isIos7) + { + // For some reasons in landscape belos the status bar is considered y=0, but in portrait it's considered y=20 + rect.origin.x = (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) ? 0 : STATUS_BAR_HEIGHT; + rect.size.width = self.view.frame.size.width-STATUS_BAR_HEIGHT; + } + } + else + { + if (!isIos7) + { + // For some reasons in landscape belos the status bar is considered y=0, but in portrait it's considered y=20 + rect.origin.y = (self.interfaceOrientation == UIInterfaceOrientationPortrait) ? STATUS_BAR_HEIGHT : 0; + rect.size.height = self.view.frame.size.height-STATUS_BAR_HEIGHT; + } + } + + return rect; } - (void)prepareMenuForReveal:(Menu)menu forcePrepare:(BOOL)forcePrepare @@ -444,19 +468,22 @@ static SlideNavigationController *singletonInstance; UIViewController *menuViewController = (menu == MenuLeft) ? self.leftMenu : self.rightMenu; UIViewController *removingMenuViewController = (menu == MenuLeft) ? self.rightMenu : self.leftMenu; - [self updateMenuFrameAndTransformAccordingToOrientation]; + //[self updateMenuFrameAndTransformAccordingToOrientation]; // If already has been added to the view (has superview) it means it has been initialized so avoid reinitializing if (menuViewController.view.superview) return; - if (self.menuRevealAnimation == MenuRevealAnimationFade || self.menuRevealAnimation == MenuRevealAnimationSlideAndFade) + if (self.menuRevealAnimation == MenuRevealAnimationFade || + self.menuRevealAnimation == MenuRevealAnimationSlideAndFade || + self.menuRevealAnimation == MenuRevealAnimationScaleAndFade) { self.menuRevealFadeAnimationView.alpha = self.menuRevealAnimationFadeMaximumAlpha; self.menuRevealFadeAnimationView.frame = menuViewController.view.bounds; } - if (self.menuRevealAnimation == MenuRevealAnimationSlide || self.menuRevealAnimation == MenuRevealAnimationSlideAndFade) + if (self.menuRevealAnimation == MenuRevealAnimationSlide || + self.menuRevealAnimation == MenuRevealAnimationSlideAndFade) { CGRect rect = menuViewController.view.frame; @@ -486,6 +513,12 @@ static SlideNavigationController *singletonInstance; menuViewController.view.frame = rect; } + if (self.menuRevealAnimation == MenuRevealAnimationScale || + self.menuRevealAnimation == MenuRevealAnimationScaleAndFade) + { + menuViewController.view.transform = CGAffineTransformScale(self.view.transform, self.menuRevealAnimationScaleMinScale, self.menuRevealAnimationScaleMinScale); + } + [removingMenuViewController.view removeFromSuperview]; [self.view.window insertSubview:menuViewController.view atIndex:0]; } @@ -581,7 +614,9 @@ static SlideNavigationController *singletonInstance; if (aPanRecognizer.state == UIGestureRecognizerStateBegan) { - [self prepareMenuForReveal:menu forcePrepare:YES]; + if (![self isMenuOpen]) + [self prepareMenuForReveal:menu forcePrepare:YES]; + self.draggingPoint = translation; lastMenu = menu; } @@ -728,4 +763,11 @@ static SlideNavigationController *singletonInstance; self.menuRevealFadeAnimationView.backgroundColor = menuRevealAnimationFadeColor; } +- (void)setMenuRevealAnimation:(MenuRevealAnimation)menuRevealAnimation +{ + _menuRevealAnimation = menuRevealAnimation; + + [self updateMenuFrameAndTransformAccordingToOrientation]; +} + @end diff --git a/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard b/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard index 0fbd340..4f07817 100755 --- a/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard +++ b/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard @@ -14,7 +14,7 @@ - + From a759310b3b824eb979f0c71329700d4141f5addb Mon Sep 17 00:00:00 2001 From: Aryan Ghassemi Date: Sun, 26 Jan 2014 14:47:32 -0800 Subject: [PATCH 2/6] - Separated all reveal animations from SlideNavigationController - Allowing a custom animation to be passed to slide menu and used for menu reveal animation --- SlideMenu.xcodeproj/project.pbxproj | 40 +++++ SlideMenu/Helper Classes/MenuViewController.m | 21 ++- .../SlideNavigationContorllerAnimator.h | 25 ++++ .../SlideNavigationContorllerAnimatorFade.h | 19 +++ .../SlideNavigationContorllerAnimatorFade.m | 70 +++++++++ .../SlideNavigationContorllerAnimatorScale.h | 18 +++ .../SlideNavigationContorllerAnimatorScale.m | 61 ++++++++ ...NavigationContorllerAnimatorScaleAndFade.h | 15 ++ ...NavigationContorllerAnimatorScaleAndFade.m | 62 ++++++++ .../SlideNavigationContorllerAnimatorSlide.h | 18 +++ .../SlideNavigationContorllerAnimatorSlide.m | 108 ++++++++++++++ ...NavigationContorllerAnimatorSlideAndFade.h | 16 ++ ...NavigationContorllerAnimatorSlideAndFade.m | 62 ++++++++ SlideMenu/Source/SlideNavigationController.h | 16 +- SlideMenu/Source/SlideNavigationController.m | 138 ++---------------- 15 files changed, 539 insertions(+), 150 deletions(-) create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimator.h create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorFade.h create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorFade.m create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.h create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.m create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.m create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.h create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlideAndFade.h create mode 100644 SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlideAndFade.m diff --git a/SlideMenu.xcodeproj/project.pbxproj b/SlideMenu.xcodeproj/project.pbxproj index b67deaf..8617671 100755 --- a/SlideMenu.xcodeproj/project.pbxproj +++ b/SlideMenu.xcodeproj/project.pbxproj @@ -24,6 +24,11 @@ 15371F141728E3B400A508F4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 15371F121728E3B400A508F4 /* InfoPlist.strings */; }; 15371F171728E3B400A508F4 /* SlideMenuTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 15371F161728E3B400A508F4 /* SlideMenuTests.m */; }; 15371F281728E44E00A508F4 /* SlideNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 15371F271728E44E00A508F4 /* SlideNavigationController.m */; }; + 15C9AC111895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC101895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m */; }; + 15C9AC141895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC131895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m */; }; + 15C9AC171895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC161895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m */; }; + 15C9AC1A1895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC191895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m */; }; + 15C9AC1D1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC1C1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m */; }; 15CBD67C172A15F900F0C53E /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 15CBD677172A15F900F0C53E /* HomeViewController.m */; }; 15CBD67D172A15F900F0C53E /* MenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 15CBD679172A15F900F0C53E /* MenuViewController.m */; }; 15CBD67E172A15F900F0C53E /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 15CBD67B172A15F900F0C53E /* ProfileViewController.m */; }; @@ -68,6 +73,17 @@ 15371F161728E3B400A508F4 /* SlideMenuTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SlideMenuTests.m; sourceTree = ""; }; 15371F261728E44E00A508F4 /* SlideNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationController.h; sourceTree = ""; }; 15371F271728E44E00A508F4 /* SlideNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationController.m; sourceTree = ""; }; + 15C9AC0F1895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorSlide.h; sourceTree = ""; }; + 15C9AC101895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorSlide.m; sourceTree = ""; }; + 15C9AC121895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorFade.h; sourceTree = ""; }; + 15C9AC131895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorFade.m; sourceTree = ""; }; + 15C9AC151895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorSlideAndFade.h; sourceTree = ""; }; + 15C9AC161895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorSlideAndFade.m; sourceTree = ""; }; + 15C9AC181895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorScale.h; sourceTree = ""; }; + 15C9AC191895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorScale.m; sourceTree = ""; }; + 15C9AC1B1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorScaleAndFade.h; sourceTree = ""; }; + 15C9AC1C1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorScaleAndFade.m; sourceTree = ""; }; + 15C9AC1E1895A832006E6F27 /* SlideNavigationContorllerAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimator.h; sourceTree = ""; }; 15CBD676172A15F900F0C53E /* HomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeViewController.h; sourceTree = ""; }; 15CBD677172A15F900F0C53E /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = ""; }; 15CBD678172A15F900F0C53E /* MenuViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuViewController.h; sourceTree = ""; }; @@ -189,6 +205,7 @@ 15371F241728E43600A508F4 /* Source */ = { isa = PBXGroup; children = ( + 15C9AC0E1895A79A006E6F27 /* Animations */, 15CBD681172A209500F0C53E /* Assets */, 15371F261728E44E00A508F4 /* SlideNavigationController.h */, 15371F271728E44E00A508F4 /* SlideNavigationController.m */, @@ -196,6 +213,24 @@ path = Source; sourceTree = ""; }; + 15C9AC0E1895A79A006E6F27 /* Animations */ = { + isa = PBXGroup; + children = ( + 15C9AC0F1895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.h */, + 15C9AC101895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m */, + 15C9AC121895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.h */, + 15C9AC131895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m */, + 15C9AC151895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.h */, + 15C9AC161895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m */, + 15C9AC181895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.h */, + 15C9AC191895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m */, + 15C9AC1B1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.h */, + 15C9AC1C1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m */, + 15C9AC1E1895A832006E6F27 /* SlideNavigationContorllerAnimator.h */, + ); + path = Animations; + sourceTree = ""; + }; 15CBD675172A15F900F0C53E /* Helper Classes */ = { isa = PBXGroup; children = ( @@ -335,12 +370,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15C9AC1D1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m in Sources */, + 15C9AC171895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m in Sources */, 15371EEF1728E3B400A508F4 /* main.m in Sources */, 15371EF31728E3B400A508F4 /* AppDelegate.m in Sources */, + 15C9AC141895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m in Sources */, 15371F281728E44E00A508F4 /* SlideNavigationController.m in Sources */, + 15C9AC111895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m in Sources */, 15CBD67C172A15F900F0C53E /* HomeViewController.m in Sources */, 997929E2187336AA00716C77 /* FriendsViewController.m in Sources */, 15CBD67D172A15F900F0C53E /* MenuViewController.m in Sources */, + 15C9AC1A1895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m in Sources */, 15CBD67E172A15F900F0C53E /* ProfileViewController.m in Sources */, 15CBD689172A22B700F0C53E /* ProfileDetailViewController.m in Sources */, ); diff --git a/SlideMenu/Helper Classes/MenuViewController.m b/SlideMenu/Helper Classes/MenuViewController.m index 7df7903..e7d9589 100755 --- a/SlideMenu/Helper Classes/MenuViewController.m +++ b/SlideMenu/Helper Classes/MenuViewController.m @@ -7,6 +7,11 @@ // #import "MenuViewController.h" +#import "SlideNavigationContorllerAnimatorFade.h" +#import "SlideNavigationContorllerAnimatorSlide.h" +#import "SlideNavigationContorllerAnimatorScale.h" +#import "SlideNavigationContorllerAnimatorScaleAndFade.h" +#import "SlideNavigationContorllerAnimatorSlideAndFade.h" @implementation MenuViewController @synthesize cellIdentifier; @@ -74,7 +79,7 @@ bundle: nil]; UIViewController *vc ; - MenuRevealAnimation revealAnimation = MenuRevealAnimationNone; + id revealAnimator; switch (indexPath.row) { @@ -96,27 +101,27 @@ break; case 4: - revealAnimation = MenuRevealAnimationNone; + revealAnimator = nil; break; case 5: - revealAnimation = MenuRevealAnimationSlide; + revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init]; break; case 6: - revealAnimation = MenuRevealAnimationFade; + revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init]; break; case 7: - revealAnimation = MenuRevealAnimationSlideAndFade; + revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] init]; break; case 8: - revealAnimation = MenuRevealAnimationScale; + revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init]; break; case 9: - revealAnimation = MenuRevealAnimationScaleAndFade; + revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] init]; break; default: @@ -127,7 +132,7 @@ [[SlideNavigationController sharedInstance] switchToViewController:vc withCompletion:nil]; else [[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{ - [SlideNavigationController sharedInstance].menuRevealAnimation = revealAnimation; + [SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator; }]; } diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimator.h b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimator.h new file mode 100644 index 0000000..be85b99 --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimator.h @@ -0,0 +1,25 @@ +// +// SlideNavigationContorllerAnimation.h +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import +#import "SlideNavigationController.h" + +@protocol SlideNavigationContorllerAnimator + +// Initial state of the view before animation starts +// This gets called right before the menu is about to reveal +- (void)prepareMenuForAnimation:(Menu)menu; + +// Animate the view based on the progress (progress is between 0 and 1) +- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress; + +// Gets called ff for any the instance of animator is being change +// You should make any cleanup that is needed +- (void)clear; + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorFade.h b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorFade.h new file mode 100644 index 0000000..2ec9b9b --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorFade.h @@ -0,0 +1,19 @@ +// +// SlideNavigationContorllerAnimationFade.h +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import +#import "SlideNavigationContorllerAnimator.h" + +@interface SlideNavigationContorllerAnimatorFade : NSObject + +@property (nonatomic, assign) CGFloat maximumFadeAlpha; +@property (nonatomic, strong) UIColor *fadeColor; + +- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha andFadeColor:(UIColor *)fadeColor; + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorFade.m b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorFade.m new file mode 100644 index 0000000..75ed354 --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorFade.m @@ -0,0 +1,70 @@ +// +// SlideNavigationContorllerAnimationFade.m +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import "SlideNavigationContorllerAnimatorFade.h" + +@interface SlideNavigationContorllerAnimatorFade() +@property (nonatomic, strong) UIView *fadeAnimationView; +@end + +@implementation SlideNavigationContorllerAnimatorFade + +#pragma mark - Initialization - + +- (id)init +{ + if (self = [self initWithMaximumFadeAlpha:.8 andFadeColor:[UIColor blackColor]]) + { + } + + return self; +} + +- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha andFadeColor:(UIColor *)fadeColor +{ + if (self = [super init]) + { + self.maximumFadeAlpha = maximumFadeAlpha; + self.fadeColor = fadeColor; + + self.fadeAnimationView = [[UIView alloc] init]; + self.fadeAnimationView.backgroundColor = self.fadeColor; + } + + return self; +} + +#pragma mark - SlideNavigationContorllerAnimation Methods - + +- (void)prepareMenuForAnimation:(Menu)menu +{ + UIViewController *menuViewController = (menu == MenuLeft) + ? [SlideNavigationController sharedInstance].leftMenu + : [SlideNavigationController sharedInstance].rightMenu; + + self.fadeAnimationView.alpha = self.maximumFadeAlpha; + self.fadeAnimationView.frame = menuViewController.view.bounds; +} + +- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress +{ + UIViewController *menuViewController = (menu == MenuLeft) + ? [SlideNavigationController sharedInstance].leftMenu + : [SlideNavigationController sharedInstance].rightMenu; + + self.fadeAnimationView.frame = menuViewController.view.bounds; + [menuViewController.view addSubview:self.fadeAnimationView]; + self.fadeAnimationView.alpha = self.maximumFadeAlpha - (self.maximumFadeAlpha *progress); +} + +- (void)clear +{ + [self.fadeAnimationView removeFromSuperview]; +} + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.h b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.h new file mode 100644 index 0000000..f2e62fd --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.h @@ -0,0 +1,18 @@ +// +// SlideNavigationContorllerAnimationScale.h +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import +#import "SlideNavigationContorllerAnimator.h" + +@interface SlideNavigationContorllerAnimatorScale : NSObject + +@property (nonatomic, assign) CGFloat minimumScale; + +- (id)initWithMinimumScale:(CGFloat)minimumScale; + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.m b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.m new file mode 100644 index 0000000..1499d26 --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.m @@ -0,0 +1,61 @@ +// +// SlideNavigationContorllerAnimationScale.m +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import "SlideNavigationContorllerAnimatorScale.h" + +@implementation SlideNavigationContorllerAnimatorScale + +#pragma mark - Initialization - + +- (id)init +{ + if (self = [self initWithMinimumScale:.8]) + { + } + + return self; +} + +- (id)initWithMinimumScale:(CGFloat)minimumScale +{ + if (self = [super init]) + { + self.minimumScale = minimumScale; + } + + return self; +} + +#pragma mark - SlideNavigationContorllerAnimation Methods - + +- (void)prepareMenuForAnimation:(Menu)menu +{ + UIViewController *menuViewController = (menu == MenuLeft) + ? [SlideNavigationController sharedInstance].leftMenu + : [SlideNavigationController sharedInstance].rightMenu; + + menuViewController.view.transform = CGAffineTransformScale([SlideNavigationController sharedInstance].view.transform, self.minimumScale, self.minimumScale); +} + +- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress +{ + UIViewController *menuViewController = (menu == MenuLeft) + ? [SlideNavigationController sharedInstance].leftMenu + : [SlideNavigationController sharedInstance].rightMenu; + + CGFloat scale = MIN(1, (1-self.minimumScale) *progress + self.minimumScale); + menuViewController.view.transform = CGAffineTransformScale([SlideNavigationController sharedInstance].view.transform, scale, scale); +} + +- (void)clear +{ + [SlideNavigationController sharedInstance].leftMenu.view.transform = CGAffineTransformScale([SlideNavigationController sharedInstance].view.transform, 1, 1); + [SlideNavigationController sharedInstance].rightMenu.view.transform = CGAffineTransformScale([SlideNavigationController sharedInstance].view.transform, 1, 1); +} + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h new file mode 100644 index 0000000..389c224 --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h @@ -0,0 +1,15 @@ +// +// SlideNavigationContorllerAnimationScaleAndFade.h +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import +#import "SlideNavigationContorllerAnimator.h" + +@interface SlideNavigationContorllerAnimatorScaleAndFade : NSObject + + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.m b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.m new file mode 100644 index 0000000..e25e10a --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.m @@ -0,0 +1,62 @@ +// +// SlideNavigationContorllerAnimationScaleAndFade.m +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import "SlideNavigationContorllerAnimatorScaleAndFade.h" +#import "SlideNavigationContorllerAnimatorFade.h" +#import "SlideNavigationContorllerAnimatorScale.h" + +@interface SlideNavigationContorllerAnimatorScaleAndFade() +@property (nonatomic, strong) SlideNavigationContorllerAnimatorFade *fadeAnimation; +@property (nonatomic, strong) SlideNavigationContorllerAnimatorScale *scaleAnimation; +@end + +@implementation SlideNavigationContorllerAnimatorScaleAndFade + +#pragma mark - Initialization - + +- (id)init +{ + if (self = [self initWithMaximumFadeAlpha:.8 fadeColor:[UIColor blackColor] andMinimumScale:.8]) + { + } + + return self; +} + +- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha fadeColor:(UIColor *)fadeColor andMinimumScale:(CGFloat)minimumScale +{ + if (self = [super init]) + { + self.fadeAnimation = [[SlideNavigationContorllerAnimatorFade alloc] initWithMaximumFadeAlpha:maximumFadeAlpha andFadeColor:fadeColor]; + self.scaleAnimation = [[SlideNavigationContorllerAnimatorScale alloc] initWithMinimumScale:minimumScale]; + } + + return self; +} + +#pragma mark - SlideNavigationContorllerAnimation Methods - + +- (void)prepareMenuForAnimation:(Menu)menu +{ + [self.fadeAnimation prepareMenuForAnimation:menu]; + [self.scaleAnimation prepareMenuForAnimation:menu]; +} + +- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress +{ + [self.fadeAnimation animateMenu:menu withProgress:progress]; + [self.scaleAnimation animateMenu:menu withProgress:progress]; +} + +- (void)clear +{ + [self.fadeAnimation clear]; + [self.scaleAnimation clear]; +} + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.h b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.h new file mode 100644 index 0000000..1337b3f --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.h @@ -0,0 +1,18 @@ +// +// SlideNavigationContorllerAnimationSlide.h +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import +#import "SlideNavigationContorllerAnimator.h" + +@interface SlideNavigationContorllerAnimatorSlide : NSObject + +@property (nonatomic, assign) CGFloat slideMovement; + +- (id)initWithSlideMovement:(CGFloat)slideMovement; + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m new file mode 100644 index 0000000..1852db3 --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m @@ -0,0 +1,108 @@ +// +// SlideNavigationContorllerAnimationSlide.m +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import "SlideNavigationContorllerAnimatorSlide.h" + +@implementation SlideNavigationContorllerAnimatorSlide + +#pragma mark - Initialization - + +- (id)init +{ + if (self = [self initWithSlideMovement:100]) + { + } + + return self; +} + +- (id)initWithSlideMovement:(CGFloat)slideMovement +{ + if (self = [super init]) + { + self.slideMovement = slideMovement; + } + + return self; +} + +#pragma mark - SlideNavigationContorllerAnimation Methods - + +- (void)prepareMenuForAnimation:(Menu)menu +{ + UIViewController *menuViewController = (menu == MenuLeft) + ? [SlideNavigationController sharedInstance].leftMenu + : [SlideNavigationController sharedInstance].rightMenu; + + UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation; + CGRect rect = menuViewController.view.frame; + + if (UIInterfaceOrientationIsLandscape(orientation)) + { + if (orientation == UIInterfaceOrientationLandscapeRight) + { + rect.origin.y = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement; + } + else + { + rect.origin.y = (menu == MenuRight) ? self.slideMovement*-1 : self.slideMovement; + } + } + else + { + if (orientation == UIInterfaceOrientationPortrait) + { + rect.origin.x = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement; + } + else + { + rect.origin.x = (menu == MenuRight) ? self.slideMovement*-1 : self.slideMovement; + } + } + + menuViewController.view.frame = rect; +} + +- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress +{ + UIViewController *menuViewController = (menu == MenuLeft) + ? [SlideNavigationController sharedInstance].leftMenu + : [SlideNavigationController sharedInstance].rightMenu; + + UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation; + + NSInteger location = (menu == MenuLeft) + ? (self.slideMovement * -1) + (self.slideMovement * progress) + : (self.slideMovement * (1-progress)); + + if (menu == MenuLeft) + location = (location > 0) ? 0 : location; + + if (menu == MenuRight) + location = (location < 0) ? 0 : location; + + CGRect rect = menuViewController.view.frame; + + if (UIInterfaceOrientationIsLandscape(orientation)) + { + rect.origin.y = (orientation == UIInterfaceOrientationLandscapeRight) ? location : location*-1; + } + else + { + rect.origin.x = (orientation == UIInterfaceOrientationPortrait) ? location : location*-1; + } + + menuViewController.view.frame = rect; +} + +- (void)clear +{ + // Nothing to do +} + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlideAndFade.h b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlideAndFade.h new file mode 100644 index 0000000..d0e0ae9 --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlideAndFade.h @@ -0,0 +1,16 @@ +// +// SlideNavigationContorllerAnimationSlideAndFade.h +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import +#import "SlideNavigationContorllerAnimator.h" + +@interface SlideNavigationContorllerAnimatorSlideAndFade : NSObject + +- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha fadeColor:(UIColor *)fadeColor andSlideMovement:(CGFloat)slideMovement; + +@end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlideAndFade.m b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlideAndFade.m new file mode 100644 index 0000000..0a51d04 --- /dev/null +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlideAndFade.m @@ -0,0 +1,62 @@ +// +// SlideNavigationContorllerAnimationSlideAndFade.m +// SlideMenu +// +// Created by Aryan Gh on 1/26/14. +// Copyright (c) 2014 Aryan Ghassemi. All rights reserved. +// + +#import "SlideNavigationContorllerAnimatorSlideAndFade.h" +#import "SlideNavigationContorllerAnimatorSlide.h" +#import "SlideNavigationContorllerAnimatorFade.h" + +@interface SlideNavigationContorllerAnimatorSlideAndFade() +@property (nonatomic, strong) SlideNavigationContorllerAnimatorFade *fadeAnimation; +@property (nonatomic, strong) SlideNavigationContorllerAnimatorSlide *slideAnimation; +@end + +@implementation SlideNavigationContorllerAnimatorSlideAndFade + +#pragma mark - Initialization - + +- (id)init +{ + if (self = [self initWithMaximumFadeAlpha:.8 fadeColor:[UIColor blackColor] andSlideMovement:100]) + { + } + + return self; +} + +- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha fadeColor:(UIColor *)fadeColor andSlideMovement:(CGFloat)slideMovement +{ + if (self = [super init]) + { + self.fadeAnimation = [[SlideNavigationContorllerAnimatorFade alloc] initWithMaximumFadeAlpha:maximumFadeAlpha andFadeColor:fadeColor]; + self.slideAnimation = [[SlideNavigationContorllerAnimatorSlide alloc] initWithSlideMovement:slideMovement]; + } + + return self; +} + +#pragma mark - SlideNavigationContorllerAnimation Methods - + +- (void)prepareMenuForAnimation:(Menu)menu +{ + [self.fadeAnimation prepareMenuForAnimation:menu]; + [self.slideAnimation prepareMenuForAnimation:menu]; +} + +- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress +{ + [self.fadeAnimation animateMenu:menu withProgress:progress]; + [self.slideAnimation animateMenu:menu withProgress:progress]; +} + +- (void)clear +{ + [self.fadeAnimation clear]; + [self.slideAnimation clear]; +} + +@end diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index 4775feb..69e24b0 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -39,15 +39,7 @@ typedef enum{ MenuRight, }Menu; -typedef enum{ - MenuRevealAnimationNone, - MenuRevealAnimationFade, - MenuRevealAnimationSlide, - MenuRevealAnimationSlideAndFade, - MenuRevealAnimationScale, - MenuRevealAnimationScaleAndFade -}MenuRevealAnimation; - +@protocol SlideNavigationContorllerAnimator; @interface SlideNavigationController : UINavigationController @property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController; @@ -58,11 +50,7 @@ typedef enum{ @property (nonatomic, strong) UIBarButtonItem *rightBarButtonItem; @property (nonatomic, assign) CGFloat portraitSlideOffset; @property (nonatomic, assign) CGFloat landscapeSlideOffset; -@property (nonatomic, assign) MenuRevealAnimation menuRevealAnimation; -@property (nonatomic, assign) CGFloat menuRevealAnimationFadeMaximumAlpha; -@property (nonatomic, strong) UIColor *menuRevealAnimationFadeColor; -@property (nonatomic, assign) CGFloat menuRevealAnimationSlideMovement; -@property (nonatomic, assign) CGFloat menuRevealAnimationScaleMinScale; +@property (nonatomic, strong) id menuRevealAnimator; + (SlideNavigationController *)sharedInstance; - (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 197188b..7995415 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -26,11 +26,11 @@ // THE SOFTWARE. #import "SlideNavigationController.h" +#import "SlideNavigationContorllerAnimator.h" @interface SlideNavigationController() @property (nonatomic, strong) UITapGestureRecognizer *tapRecognizer; @property (nonatomic, strong) UIPanGestureRecognizer *panRecognizer; -@property (nonatomic, strong) UIView *menuRevealFadeAnimationView; @property (nonatomic, assign) CGPoint draggingPoint; @end @@ -44,9 +44,6 @@ #define MENU_SHADOW_OPACITY 1 #define MENU_DEFAULT_SLIDE_OFFSET 60 #define MENU_FAST_VELOCITY_FOR_SWIPE_FOLLOW_DIRECTION 1200 -#define MENU_REVEAL_ANIMATION_DEFAULT_SLIDE_MOVEMENT 100 -#define MENU_REVEAL_ANIMATION_DEFAULT_FADE_MAXIMUM_ALPHA .8 -#define MENU_REVEAL_ANIMATION_DEFAULT_SCALE_MINIMUM_SCALE .85 #define STATUS_BAR_HEIGHT 20 static SlideNavigationController *singletonInstance; @@ -90,10 +87,6 @@ static SlideNavigationController *singletonInstance; - (void)setup { - self.menuRevealAnimationSlideMovement = MENU_REVEAL_ANIMATION_DEFAULT_SLIDE_MOVEMENT; - self.menuRevealAnimationScaleMinScale = MENU_REVEAL_ANIMATION_DEFAULT_SCALE_MINIMUM_SCALE; - self.menuRevealAnimationFadeMaximumAlpha = MENU_REVEAL_ANIMATION_DEFAULT_FADE_MAXIMUM_ALPHA; - self.menuRevealAnimation = MenuRevealAnimationSlideAndFade; self.landscapeSlideOffset = MENU_DEFAULT_SLIDE_OFFSET; self.portraitSlideOffset = MENU_DEFAULT_SLIDE_OFFSET; self.avoidSwitchingToSameClassViewController = YES; @@ -108,7 +101,7 @@ static SlideNavigationController *singletonInstance; self.view.layer.rasterizationScale = [UIScreen mainScreen].scale; [self setEnableSwipeGesture:YES]; - [self updateMenuFrameAndTransformAccordingToOrientation]; + [self updateMenuFrameAndTransformAccordingToOrientation]; // Do we need this? } - (void)viewWillLayoutSubviews @@ -376,57 +369,11 @@ static SlideNavigationController *singletonInstance; - (void)updateMenuAnimation:(Menu)menu { - if (self.menuRevealAnimation == MenuRevealAnimationNone) - return; - - UIViewController *menuViewController = (menu == MenuLeft) ? self.leftMenu : self.rightMenu; - CGFloat progress = (menu == MenuLeft) ? (self.horizontalLocation / self.maxXForDragging) : (self.horizontalLocation / self.minXForDragging); - - if (self.menuRevealAnimation == MenuRevealAnimationFade || - self.menuRevealAnimation == MenuRevealAnimationSlideAndFade || - self.menuRevealAnimation == MenuRevealAnimationScaleAndFade) - { - self.menuRevealFadeAnimationView.frame = menuViewController.view.bounds; - [menuViewController.view addSubview:self.menuRevealFadeAnimationView]; - self.menuRevealFadeAnimationView.alpha = self.menuRevealAnimationFadeMaximumAlpha - (self.menuRevealAnimationFadeMaximumAlpha *progress); - } - if (self.menuRevealAnimation == MenuRevealAnimationSlide || - self.menuRevealAnimation == MenuRevealAnimationSlideAndFade) - { - NSInteger location = (menu == MenuLeft) - ? (self.menuRevealAnimationSlideMovement * -1) + (self.menuRevealAnimationSlideMovement * progress) - : (self.menuRevealAnimationSlideMovement * (1-progress)); - - if (menu == MenuLeft) - location = (location > 0) ? 0 : location; - - if (menu == MenuRight) - location = (location < 0) ? 0 : location; - - CGRect rect = [self initialRectForMenu]; - - if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) - { - rect.origin.y = (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) ? location : location*-1; - } - else - { - rect.origin.x = (self.interfaceOrientation == UIInterfaceOrientationPortrait) ? location : location*-1; - } - - menuViewController.view.frame = rect; - } - - if (self.menuRevealAnimation == MenuRevealAnimationScale || - self.menuRevealAnimation == MenuRevealAnimationScaleAndFade) - { - CGFloat scale = MIN(1, (1-self.menuRevealAnimationScaleMinScale) *progress + self.menuRevealAnimationScaleMinScale); - menuViewController.view.transform = CGAffineTransformScale(self.view.transform, scale, scale); - } + [self.menuRevealAnimator animateMenu:menu withProgress:progress]; } - (CGRect)initialRectForMenu @@ -461,63 +408,16 @@ static SlideNavigationController *singletonInstance; - (void)prepareMenuForReveal:(Menu)menu forcePrepare:(BOOL)forcePrepare { - // If menu is already open don't prepare, unless forcePrepare is set to true - if ([self isMenuOpen] && !forcePrepare) - return; - UIViewController *menuViewController = (menu == MenuLeft) ? self.leftMenu : self.rightMenu; UIViewController *removingMenuViewController = (menu == MenuLeft) ? self.rightMenu : self.leftMenu; - //[self updateMenuFrameAndTransformAccordingToOrientation]; - + // If menu is already open don't prepare, unless forcePrepare is set to true // If already has been added to the view (has superview) it means it has been initialized so avoid reinitializing - if (menuViewController.view.superview) + if (([self isMenuOpen] && !forcePrepare) || menuViewController.view.superview) return; - if (self.menuRevealAnimation == MenuRevealAnimationFade || - self.menuRevealAnimation == MenuRevealAnimationSlideAndFade || - self.menuRevealAnimation == MenuRevealAnimationScaleAndFade) - { - self.menuRevealFadeAnimationView.alpha = self.menuRevealAnimationFadeMaximumAlpha; - self.menuRevealFadeAnimationView.frame = menuViewController.view.bounds; - } - - if (self.menuRevealAnimation == MenuRevealAnimationSlide || - self.menuRevealAnimation == MenuRevealAnimationSlideAndFade) - { - CGRect rect = menuViewController.view.frame; - - if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) - { - if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) - { - rect.origin.y = (menu == MenuLeft) ? self.menuRevealAnimationSlideMovement*-1 : self.menuRevealAnimationSlideMovement; - } - else - { - rect.origin.y = (menu == MenuRight) ? self.menuRevealAnimationSlideMovement*-1 : self.menuRevealAnimationSlideMovement; - } - } - else - { - if (self.interfaceOrientation == UIInterfaceOrientationPortrait) - { - rect.origin.x = (menu == MenuLeft) ? self.menuRevealAnimationSlideMovement*-1 : self.menuRevealAnimationSlideMovement; - } - else - { - rect.origin.x = (menu == MenuRight) ? self.menuRevealAnimationSlideMovement*-1 : self.menuRevealAnimationSlideMovement; - } - } - - menuViewController.view.frame = rect; - } - - if (self.menuRevealAnimation == MenuRevealAnimationScale || - self.menuRevealAnimation == MenuRevealAnimationScaleAndFade) - { - menuViewController.view.transform = CGAffineTransformScale(self.view.transform, self.menuRevealAnimationScaleMinScale, self.menuRevealAnimationScaleMinScale); - } + menuViewController.view.frame = [self initialRectForMenu]; + [self.menuRevealAnimator prepareMenuForAnimation:menu]; [removingMenuViewController.view removeFromSuperview]; [self.view.window insertSubview:menuViewController.view atIndex:0]; @@ -745,29 +645,11 @@ static SlideNavigationController *singletonInstance; } } -- (UIView *)menuRevealFadeAnimationView +- (void)setMenuRevealAnimator:(id)menuRevealAnimator { - if (!_menuRevealFadeAnimationView) - { - _menuRevealFadeAnimationView = [[UIView alloc] init]; - _menuRevealFadeAnimationView.backgroundColor = [UIColor blackColor]; - _menuRevealFadeAnimationView.frame = self.view.bounds; - } + [self.menuRevealAnimator clear]; - return _menuRevealFadeAnimationView; -} - -- (void)setMenuRevealAnimationFadeColor:(UIColor *)menuRevealAnimationFadeColor -{ - _menuRevealAnimationFadeColor = menuRevealAnimationFadeColor; - self.menuRevealFadeAnimationView.backgroundColor = menuRevealAnimationFadeColor; -} - -- (void)setMenuRevealAnimation:(MenuRevealAnimation)menuRevealAnimation -{ - _menuRevealAnimation = menuRevealAnimation; - - [self updateMenuFrameAndTransformAccordingToOrientation]; + _menuRevealAnimator = menuRevealAnimator; } @end From 93b7afcfd8e9429ca8c0730df1502709f4d21216 Mon Sep 17 00:00:00 2001 From: Aryan Ghassemi Date: Sun, 26 Jan 2014 15:05:21 -0800 Subject: [PATCH 3/6] - Implemented clear for slide animation - Fixed an issue with scale animation --- .../SlideNavigationContorllerAnimatorScale.m | 4 +-- .../SlideNavigationContorllerAnimatorSlide.m | 27 ++++++++++++++++++- SlideMenu/Source/SlideNavigationController.m | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.m b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.m index 1499d26..49b2a2e 100644 --- a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.m +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScale.m @@ -14,7 +14,7 @@ - (id)init { - if (self = [self initWithMinimumScale:.8]) + if (self = [self initWithMinimumScale:.9]) { } @@ -39,7 +39,7 @@ ? [SlideNavigationController sharedInstance].leftMenu : [SlideNavigationController sharedInstance].rightMenu; - menuViewController.view.transform = CGAffineTransformScale([SlideNavigationController sharedInstance].view.transform, self.minimumScale, self.minimumScale); + menuViewController.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, self.minimumScale, self.minimumScale); } - (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m index 1852db3..7ee4352 100644 --- a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorSlide.m @@ -102,7 +102,32 @@ - (void)clear { - // Nothing to do + [self clearMenu:MenuLeft]; + [self clearMenu:MenuRight]; +} + +#pragma mark - Private Method - + +- (void)clearMenu:(Menu)menu +{ + UIViewController *menuViewController = (menu == MenuLeft) + ? [SlideNavigationController sharedInstance].leftMenu + : [SlideNavigationController sharedInstance].rightMenu; + + UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation; + + CGRect rect = menuViewController.view.frame; + + if (UIInterfaceOrientationIsLandscape(orientation)) + { + rect.origin.y = 0; + } + else + { + rect.origin.x = 0; + } + + menuViewController.view.frame = rect; } @end diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 7995415..7c45223 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -416,7 +416,7 @@ static SlideNavigationController *singletonInstance; if (([self isMenuOpen] && !forcePrepare) || menuViewController.view.superview) return; - menuViewController.view.frame = [self initialRectForMenu]; + //menuViewController.view.frame = [self initialRectForMenu]; [self.menuRevealAnimator prepareMenuForAnimation:menu]; [removingMenuViewController.view removeFromSuperview]; From f1025d779266ffe399d3c8431d6b21932b947df5 Mon Sep 17 00:00:00 2001 From: Aryan Ghassemi Date: Sun, 26 Jan 2014 15:27:57 -0800 Subject: [PATCH 4/6] - Some cleanup - Structured menu for a better presentation of slide menu features --- SlideMenu/Helper Classes/MenuViewController.h | 2 +- SlideMenu/Helper Classes/MenuViewController.m | 208 ++++++++++-------- ...NavigationContorllerAnimatorScaleAndFade.h | 1 + .../en.lproj/MainStoryboard_iPhone.storyboard | 5 +- 4 files changed, 122 insertions(+), 94 deletions(-) diff --git a/SlideMenu/Helper Classes/MenuViewController.h b/SlideMenu/Helper Classes/MenuViewController.h index 412e0b8..0d2e7aa 100755 --- a/SlideMenu/Helper Classes/MenuViewController.h +++ b/SlideMenu/Helper Classes/MenuViewController.h @@ -9,7 +9,7 @@ #import #import "SlideNavigationController.h" -@interface MenuViewController : UIViewController +@interface MenuViewController : UIViewController @property (nonatomic, strong) NSString *cellIdentifier; diff --git a/SlideMenu/Helper Classes/MenuViewController.m b/SlideMenu/Helper Classes/MenuViewController.m index e7d9589..646ea43 100755 --- a/SlideMenu/Helper Classes/MenuViewController.m +++ b/SlideMenu/Helper Classes/MenuViewController.m @@ -18,56 +18,74 @@ #pragma mark - UITableView Delegate & Datasrouce - +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 2; +} + - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 10; + return (section == 0) ? 4 : 6; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + return (section == 0) ? @"Navigation" : @"Menu Animation"; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellIdentifier]; - switch (indexPath.row) + if (indexPath.section == 0) { - case 0: - cell.textLabel.text = @"Home"; - break; - - case 1: - cell.textLabel.text = @"Profile"; - break; - - case 2: - cell.textLabel.text = @"Friends"; - break; - - case 3: - cell.textLabel.text = @"Sign Out"; - break; - - case 4: - cell.textLabel.text = @"No Animation"; - break; - - case 5: - cell.textLabel.text = @"Slide Animation"; - break; - - case 6: - cell.textLabel.text = @"Fade Animation"; - break; - - case 7: - cell.textLabel.text = @"Slide And Fade Animation"; - break; - - case 8: - cell.textLabel.text = @"Scale Animation"; - break; - - case 9: - cell.textLabel.text = @"Scale And Fade Animation"; - break; + switch (indexPath.row) + { + case 0: + cell.textLabel.text = @"Home"; + break; + + case 1: + cell.textLabel.text = @"Profile"; + break; + + case 2: + cell.textLabel.text = @"Friends"; + break; + + case 3: + cell.textLabel.text = @"Sign Out"; + break; + } + } + else + { + switch (indexPath.row) + { + case 0: + cell.textLabel.text = @"No Animation"; + break; + + case 1: + cell.textLabel.text = @"Slide Animation"; + break; + + case 2: + cell.textLabel.text = @"Fade Animation"; + break; + + case 3: + cell.textLabel.text = @"Slide And Fade Animation"; + break; + + case 4: + cell.textLabel.text = @"Scale Animation"; + break; + + case 5: + cell.textLabel.text = @"Scale And Fade Animation"; + break; + } } return cell; @@ -78,62 +96,70 @@ UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil]; - UIViewController *vc ; - id revealAnimator; - - switch (indexPath.row) + if (indexPath.section == 0) { - case 0: - vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"]; - break; - - case 1: - vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"ProfileViewController"]; - break; - - case 2: - vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"FriendsViewController"]; - break; - - case 3: - [[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES]; - return; - break; - - case 4: - revealAnimator = nil; - break; - - case 5: - revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init]; - break; - - case 6: - revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init]; - break; - - case 7: - revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] init]; - break; - - case 8: - revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init]; - break; - - case 9: - revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] init]; - break; - - default: - return; - } - - if (vc) + UIViewController *vc ; + + switch (indexPath.row) + { + case 0: + vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"]; + break; + + case 1: + vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"ProfileViewController"]; + break; + + case 2: + vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"FriendsViewController"]; + break; + + case 3: + [[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES]; + return; + break; + } + [[SlideNavigationController sharedInstance] switchToViewController:vc withCompletion:nil]; + } else + { + id revealAnimator; + + switch (indexPath.row) + { + case 0: + revealAnimator = nil; + break; + + case 1: + revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init]; + break; + + case 2: + revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init]; + break; + + case 3: + revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.7 fadeColor:[UIColor purpleColor] andSlideMovement:100]; + break; + + case 4: + revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init]; + break; + + case 5: + revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] initWithMaximumFadeAlpha:.6 fadeColor:[UIColor blueColor] andMinimumScale:.7]; + break; + + default: + return; + } + [[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{ [SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator; }]; + } } @end diff --git a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h index 389c224..398e645 100644 --- a/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h +++ b/SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h @@ -11,5 +11,6 @@ @interface SlideNavigationContorllerAnimatorScaleAndFade : NSObject +- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha fadeColor:(UIColor *)fadeColor andMinimumScale:(CGFloat)minimumScale; @end diff --git a/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard b/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard index 4f07817..2ac4a4c 100755 --- a/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard +++ b/SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard @@ -14,9 +14,10 @@ - - + + + From 835e8bedd1cf41674632977bf58803c6ff5e4d38 Mon Sep 17 00:00:00 2001 From: Aryan Ghassemi Date: Sun, 26 Jan 2014 15:47:01 -0800 Subject: [PATCH 5/6] - Fixed a bug where menu animation does not get completed when switching to another view controller because that viewController is not presenting the menu (delegate return NO or not implemented) --- SlideMenu/Source/SlideNavigationController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 7c45223..9149752 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -370,8 +370,8 @@ static SlideNavigationController *singletonInstance; - (void)updateMenuAnimation:(Menu)menu { CGFloat progress = (menu == MenuLeft) - ? (self.horizontalLocation / self.maxXForDragging) - : (self.horizontalLocation / self.minXForDragging); + ? (self.horizontalLocation / (self.horizontalSize - self.slideOffset)) + : (self.horizontalLocation / ((self.horizontalSize - self.slideOffset) * -1)); [self.menuRevealAnimator animateMenu:menu withProgress:progress]; } From 2b3be430f36d55a1b5729c85e9b1c95a21dddfad Mon Sep 17 00:00:00 2001 From: Aryan Ghassemi Date: Mon, 27 Jan 2014 20:17:32 -0800 Subject: [PATCH 6/6] =?UTF-8?q?-=20Cleanup=20-=20Fixed=20typo=20in=20prope?= =?UTF-8?q?rty=20name=20renamed=20=E2=80=9CleftbarButtonItem=E2=80=9D=20to?= =?UTF-8?q?=20=E2=80=9CleftBarButtonItem=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlideMenu/Source/SlideNavigationController.h | 2 +- SlideMenu/Source/SlideNavigationController.m | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index 69e24b0..9b4bd49 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -46,7 +46,7 @@ typedef enum{ @property (nonatomic, assign) BOOL enableSwipeGesture; @property (nonatomic, strong) UIViewController *rightMenu; @property (nonatomic, strong) UIViewController *leftMenu; -@property (nonatomic, strong) UIBarButtonItem *leftbarButtonItem; +@property (nonatomic, strong) UIBarButtonItem *leftBarButtonItem; @property (nonatomic, strong) UIBarButtonItem *rightBarButtonItem; @property (nonatomic, assign) CGFloat portraitSlideOffset; @property (nonatomic, assign) CGFloat landscapeSlideOffset; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 9149752..bb73dce 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -101,7 +101,6 @@ static SlideNavigationController *singletonInstance; self.view.layer.rasterizationScale = [UIScreen mainScreen].scale; [self setEnableSwipeGesture:YES]; - [self updateMenuFrameAndTransformAccordingToOrientation]; // Do we need this? } - (void)viewWillLayoutSubviews @@ -270,7 +269,7 @@ static SlideNavigationController *singletonInstance; - (UIBarButtonItem *)barButtonItemForMenu:(Menu)menu { SEL selector = (menu == MenuLeft) ? @selector(leftMenuSelected:) : @selector(righttMenuSelected:); - UIBarButtonItem *customButton = (menu == MenuLeft) ? self.leftbarButtonItem : self.rightBarButtonItem; + UIBarButtonItem *customButton = (menu == MenuLeft) ? self.leftBarButtonItem : self.rightBarButtonItem; if (customButton) { @@ -416,7 +415,6 @@ static SlideNavigationController *singletonInstance; if (([self isMenuOpen] && !forcePrepare) || menuViewController.view.superview) return; - //menuViewController.view.frame = [self initialRectForMenu]; [self.menuRevealAnimator prepareMenuForAnimation:menu]; [removingMenuViewController.view removeFromSuperview];