diff --git a/Demo1.gif b/Demo1.gif new file mode 100644 index 00000000..bb3306d5 Binary files /dev/null and b/Demo1.gif differ diff --git a/Examples/Storyboards/RESideMenuStoryboardsExample.xcodeproj/project.xcworkspace/xcshareddata/RESideMenuStoryboardsExample.xccheckout b/Examples/Storyboards/RESideMenuStoryboardsExample.xcodeproj/project.xcworkspace/xcshareddata/RESideMenuStoryboardsExample.xccheckout index 6a4fafc2..0bb4915a 100644 --- a/Examples/Storyboards/RESideMenuStoryboardsExample.xcodeproj/project.xcworkspace/xcshareddata/RESideMenuStoryboardsExample.xccheckout +++ b/Examples/Storyboards/RESideMenuStoryboardsExample.xcodeproj/project.xcworkspace/xcshareddata/RESideMenuStoryboardsExample.xccheckout @@ -11,17 +11,17 @@ IDESourceControlProjectOriginsDictionary 4D9AE519C7D7E765CA7498EFD8B3BB24ACB11215 - ssh://github.com/romaonthego/RESideMenu.git + https://github.com/leiyong316/RESideMenu.git IDESourceControlProjectPath - Examples/Storyboards/RESideMenuStoryboardsExample.xcodeproj/project.xcworkspace + Examples/Storyboards/RESideMenuStoryboardsExample.xcodeproj IDESourceControlProjectRelativeInstallPathDictionary 4D9AE519C7D7E765CA7498EFD8B3BB24ACB11215 ../../../.. IDESourceControlProjectURL - ssh://github.com/romaonthego/RESideMenu.git + https://github.com/leiyong316/RESideMenu.git IDESourceControlProjectVersion 111 IDESourceControlProjectWCCIdentifier diff --git a/Examples/Storyboards/RESideMenuStoryboardsExample/DEMORootViewController.m b/Examples/Storyboards/RESideMenuStoryboardsExample/DEMORootViewController.m index 4086ab21..502b0862 100644 --- a/Examples/Storyboards/RESideMenuStoryboardsExample/DEMORootViewController.m +++ b/Examples/Storyboards/RESideMenuStoryboardsExample/DEMORootViewController.m @@ -17,6 +17,7 @@ @implementation DEMORootViewController - (void)awakeFromNib { + self.sideMenuType = RESideMenuTypeSlip; self.menuPreferredStatusBarStyle = UIStatusBarStyleLightContent; self.contentViewShadowColor = [UIColor blackColor]; self.contentViewShadowOffset = CGSizeMake(0, 0); diff --git a/README.md b/README.md index ee577f95..e5ac276e 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,11 @@ Since version 4.0 you can add menu view controllers on both left and right sides RESideMenu Screenshot RESideMenu Screenshot +slip type. + +RESideMenu Screenshot1                   +RESideMenu Screenshot1 + ## Requirements * Xcode 6 or higher * Apple LLVM compiler diff --git a/RESideMenu/RESideMenu.h b/RESideMenu/RESideMenu.h index 6682ae1b..67615850 100644 --- a/RESideMenu/RESideMenu.h +++ b/RESideMenu/RESideMenu.h @@ -26,6 +26,11 @@ #import #import "UIViewController+RESideMenu.h" +typedef NS_ENUM(NSInteger, RESideMenuType) { + RESideMenuTypeScale, //default + RESideMenuTypeSlip +}; + #ifndef IBInspectable #define IBInspectable #endif @@ -73,6 +78,8 @@ @property (assign, readwrite, nonatomic) IBInspectable BOOL bouncesHorizontally; @property (assign, readwrite, nonatomic) UIStatusBarStyle menuPreferredStatusBarStyle; @property (assign, readwrite, nonatomic) IBInspectable BOOL menuPrefersStatusBarHidden; +@property (assign, readwrite, nonatomic) RESideMenuType sideMenuType; + - (id)initWithContentViewController:(UIViewController *)contentViewController leftMenuViewController:(UIViewController *)leftMenuViewController diff --git a/RESideMenu/RESideMenu.m b/RESideMenu/RESideMenu.m index b2da249e..13607da4 100644 --- a/RESideMenu/RESideMenu.m +++ b/RESideMenu/RESideMenu.m @@ -115,6 +115,8 @@ - (void)commonInit _contentViewInLandscapeOffsetCenterX = 30.f; _contentViewInPortraitOffsetCenterX = 30.f; _contentViewScaleValue = 0.7f; + + _sideMenuType = RESideMenuTypeScale; } #pragma mark - @@ -282,16 +284,18 @@ - (void)showLeftMenuViewController [self resetContentViewScale]; [UIView animateWithDuration:self.animationDuration animations:^{ - if (self.scaleContentView) { - self.contentViewContainer.transform = CGAffineTransformMakeScale(self.contentViewScaleValue, self.contentViewScaleValue); - } else { - self.contentViewContainer.transform = CGAffineTransformIdentity; + if (_sideMenuType == RESideMenuTypeScale) { + if (self.scaleContentView) { + self.contentViewContainer.transform = CGAffineTransformMakeScale(self.contentViewScaleValue, self.contentViewScaleValue); + } else { + self.contentViewContainer.transform = CGAffineTransformIdentity; + } } if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) { - self.contentViewContainer.center = CGPointMake((UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? self.contentViewInLandscapeOffsetCenterX + CGRectGetWidth(self.view.frame) : self.contentViewInPortraitOffsetCenterX + CGRectGetWidth(self.view.frame)), self.contentViewContainer.center.y); + self.contentViewContainer.center = CGPointMake((UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? self.contentViewInLandscapeOffsetCenterX + CGRectGetWidth(self.view.frame) : self.contentViewInPortraitOffsetCenterX + CGRectGetWidth(self.view.frame)+(_sideMenuType==RESideMenuTypeSlip?50:0)), self.contentViewContainer.center.y); } else { - self.contentViewContainer.center = CGPointMake((UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? self.contentViewInLandscapeOffsetCenterX + CGRectGetHeight(self.view.frame) : self.contentViewInPortraitOffsetCenterX + CGRectGetWidth(self.view.frame)), self.contentViewContainer.center.y); + self.contentViewContainer.center = CGPointMake((UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? self.contentViewInLandscapeOffsetCenterX + CGRectGetHeight(self.view.frame) : self.contentViewInPortraitOffsetCenterX + CGRectGetWidth(self.view.frame)+(_sideMenuType==RESideMenuTypeSlip?50:0)), self.contentViewContainer.center.y); } self.menuViewContainer.alpha = !self.fadeMenuView ?: 1.0f; @@ -328,12 +332,15 @@ - (void)showRightMenuViewController [[UIApplication sharedApplication] beginIgnoringInteractionEvents]; [UIView animateWithDuration:self.animationDuration animations:^{ - if (self.scaleContentView) { - self.contentViewContainer.transform = CGAffineTransformMakeScale(self.contentViewScaleValue, self.contentViewScaleValue); - } else { - self.contentViewContainer.transform = CGAffineTransformIdentity; + if (_sideMenuType == RESideMenuTypeScale) { + if (self.scaleContentView) { + self.contentViewContainer.transform = CGAffineTransformMakeScale(self.contentViewScaleValue, self.contentViewScaleValue); + } else { + self.contentViewContainer.transform = CGAffineTransformIdentity; + } } - self.contentViewContainer.center = CGPointMake((UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? -self.contentViewInLandscapeOffsetCenterX : -self.contentViewInPortraitOffsetCenterX), self.contentViewContainer.center.y); + + self.contentViewContainer.center = CGPointMake((UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? -self.contentViewInLandscapeOffsetCenterX : -self.contentViewInPortraitOffsetCenterX-(_sideMenuType==RESideMenuTypeSlip?50:0)), self.contentViewContainer.center.y); self.menuViewContainer.alpha = !self.fadeMenuView ?: 1.0f; self.contentViewContainer.alpha = self.contentViewFadeOutAlpha; @@ -592,15 +599,17 @@ - (void)panGestureRecognized:(UIPanGestureRecognizer *)recognizer self.menuViewContainer.alpha = !self.fadeMenuView ?: delta; self.contentViewContainer.alpha = 1 - (1 - self.contentViewFadeOutAlpha) * delta; - - if (self.scaleBackgroundImageView) { - self.backgroundImageView.transform = CGAffineTransformMakeScale(backgroundViewScale, backgroundViewScale); - } - - if (self.scaleMenuView) { - self.menuViewContainer.transform = CGAffineTransformMakeScale(menuViewScale, menuViewScale); + + if (_sideMenuType == RESideMenuTypeScale) { + if (self.scaleBackgroundImageView) { + self.backgroundImageView.transform = CGAffineTransformMakeScale(backgroundViewScale, backgroundViewScale); + } + + if (self.scaleMenuView) { + self.menuViewContainer.transform = CGAffineTransformMakeScale(menuViewScale, menuViewScale); + } } - + if (self.scaleBackgroundImageView) { if (backgroundViewScale < 1) { self.backgroundImageView.transform = CGAffineTransformIdentity; @@ -637,14 +646,16 @@ - (void)panGestureRecognized:(UIPanGestureRecognizer *)recognizer } self.didNotifyDelegate = YES; } - - if (contentViewScale > 1) { - CGFloat oppositeScale = (1 - (contentViewScale - 1)); - self.contentViewContainer.transform = CGAffineTransformMakeScale(oppositeScale, oppositeScale); - self.contentViewContainer.transform = CGAffineTransformTranslate(self.contentViewContainer.transform, point.x, 0); - } else { - self.contentViewContainer.transform = CGAffineTransformMakeScale(contentViewScale, contentViewScale); - self.contentViewContainer.transform = CGAffineTransformTranslate(self.contentViewContainer.transform, point.x, 0); + + if (_sideMenuType == RESideMenuTypeScale) { + if (contentViewScale > 1) { + CGFloat oppositeScale = (1 - (contentViewScale - 1)); + self.contentViewContainer.transform = CGAffineTransformMakeScale(oppositeScale, oppositeScale); + self.contentViewContainer.transform = CGAffineTransformTranslate(self.contentViewContainer.transform, point.x, 0); + } else { + self.contentViewContainer.transform = CGAffineTransformMakeScale(contentViewScale, contentViewScale); + self.contentViewContainer.transform = CGAffineTransformTranslate(self.contentViewContainer.transform, point.x, 0); + } } self.leftMenuViewController.view.hidden = self.contentViewContainer.frame.origin.x < 0; diff --git a/ScreenShot1.png b/ScreenShot1.png new file mode 100644 index 00000000..636f48ed Binary files /dev/null and b/ScreenShot1.png differ