Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add RESideMenuType type #209

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Demo1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>4D9AE519C7D7E765CA7498EFD8B3BB24ACB11215</key>
<string>ssh://github.com/romaonthego/RESideMenu.git</string>
<string>https://github.com/leiyong316/RESideMenu.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Examples/Storyboards/RESideMenuStoryboardsExample.xcodeproj/project.xcworkspace</string>
<string>Examples/Storyboards/RESideMenuStoryboardsExample.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>4D9AE519C7D7E765CA7498EFD8B3BB24ACB11215</key>
<string>../../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/romaonthego/RESideMenu.git</string>
<string>https://github.com/leiyong316/RESideMenu.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation DEMORootViewController

- (void)awakeFromNib
{
self.sideMenuType = RESideMenuTypeSlip;
self.menuPreferredStatusBarStyle = UIStatusBarStyleLightContent;
self.contentViewShadowColor = [UIColor blackColor];
self.contentViewShadowOffset = CGSizeMake(0, 0);
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Since version 4.0 you can add menu view controllers on both left and right sides
<img src="https://github.com/romaonthego/RESideMenu/raw/master/Screenshot.png" alt="RESideMenu Screenshot" width="400" height="568" />
<img src="https://raw.githubusercontent.com/romaonthego/RESideMenu/master/Demo.gif?2" alt="RESideMenu Screenshot" width="320" height="568" />

slip type.

<img src="https://github.com/leiyong316/RESideMenu/blob/master/ScreenShot1.png" alt="RESideMenu Screenshot1" width="320" height="568" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="https://github.com/leiyong316/RESideMenu/blob/master/Demo1.gif?2" alt="RESideMenu Screenshot1" width="320" height="568" />

## Requirements
* Xcode 6 or higher
* Apple LLVM compiler
Expand Down
7 changes: 7 additions & 0 deletions RESideMenu/RESideMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
#import <UIKit/UIKit.h>
#import "UIViewController+RESideMenu.h"

typedef NS_ENUM(NSInteger, RESideMenuType) {
RESideMenuTypeScale, //default
RESideMenuTypeSlip
};

#ifndef IBInspectable
#define IBInspectable
#endif
Expand Down Expand Up @@ -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
Expand Down
65 changes: 38 additions & 27 deletions RESideMenu/RESideMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ - (void)commonInit
_contentViewInLandscapeOffsetCenterX = 30.f;
_contentViewInPortraitOffsetCenterX = 30.f;
_contentViewScaleValue = 0.7f;

_sideMenuType = RESideMenuTypeScale;
}

#pragma mark -
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Binary file added ScreenShot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.