Skip to content

Commit 6a9333e

Browse files
committed
Merge pull request #113 from aryaxt/Develop
Version 1.4.5
2 parents 07e1420 + eb2de83 commit 6a9333e

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

SlideMenu/AppDelegate.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
2323

2424
[SlideNavigationController sharedInstance].rightMenu = rightMenu;
2525
[SlideNavigationController sharedInstance].leftMenu = leftMenu;
26+
[SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18;
2627

2728
// Creating a custom bar button for right menu
2829
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];

SlideMenu/Helper Classes/RightMenuViewController.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,38 +80,46 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
8080
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
8181
{
8282
id <SlideNavigationContorllerAnimator> revealAnimator;
83+
CGFloat animationDuration = 0;
8384

8485
switch (indexPath.row)
8586
{
8687
case 0:
8788
revealAnimator = nil;
89+
animationDuration = .19;
8890
break;
8991

9092
case 1:
9193
revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init];
94+
animationDuration = .19;
9295
break;
9396

9497
case 2:
9598
revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init];
99+
animationDuration = .18;
96100
break;
97101

98102
case 3:
99103
revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.8 fadeColor:[UIColor blackColor] andSlideMovement:100];
104+
animationDuration = .19;
100105
break;
101106

102107
case 4:
103108
revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init];
109+
animationDuration = .22;
104110
break;
105111

106112
case 5:
107113
revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] initWithMaximumFadeAlpha:.6 fadeColor:[UIColor blackColor] andMinimumScale:.8];
114+
animationDuration = .22;
108115
break;
109116

110117
default:
111118
return;
112119
}
113120

114121
[[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{
122+
[SlideNavigationController sharedInstance].menuRevealAnimationDuration = animationDuration;
115123
[SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator;
116124
}];
117125
}

SlideMenu/Source/SlideNavigationController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ extern NSString *const SlideNavigationControllerDidReveal;
5858
@property (nonatomic, assign) CGFloat portraitSlideOffset;
5959
@property (nonatomic, assign) CGFloat landscapeSlideOffset;
6060
@property (nonatomic, assign) CGFloat panGestureSideOffset;
61+
@property (nonatomic, assign) CGFloat menuRevealAnimationDuration;
62+
@property (nonatomic, assign) UIViewAnimationOptions menuRevealAnimationOption;
6163
@property (nonatomic, strong) id <SlideNavigationContorllerAnimator> menuRevealAnimator;
6264

6365
+ (SlideNavigationController *)sharedInstance;

SlideMenu/Source/SlideNavigationController.m

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ @implementation SlideNavigationController
4848
NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal";
4949

5050
#define MENU_SLIDE_ANIMATION_DURATION .3
51+
#define MENU_SLIDE_ANIMATION_OPTION UIViewAnimationOptionCurveEaseOut
5152
#define MENU_QUICK_SLIDE_ANIMATION_DURATION .18
5253
#define MENU_IMAGE @"menu-button"
5354
#define MENU_SHADOW_RADIUS 10
@@ -101,13 +102,25 @@ - (id)initWithRootViewController:(UIViewController *)rootViewController
101102
return self;
102103
}
103104

105+
- (id)initWithNavigationBarClass:(Class)navigationBarClass toolbarClass:(Class)toolbarClass
106+
{
107+
if (self = [super initWithNavigationBarClass:navigationBarClass toolbarClass:toolbarClass])
108+
{
109+
[self setup];
110+
}
111+
112+
return self;
113+
}
114+
104115
- (void)setup
105116
{
106117
if (singletonInstance)
107118
NSLog(@"Singleton instance already exists. You can only instantiate one instance of SlideNavigationController. This could cause major issues");
108119

109120
singletonInstance = self;
110121

122+
self.menuRevealAnimationDuration = MENU_SLIDE_ANIMATION_DURATION;
123+
self.menuRevealAnimationOption = MENU_SLIDE_ANIMATION_OPTION;
111124
self.landscapeSlideOffset = MENU_DEFAULT_SLIDE_OFFSET;
112125
self.portraitSlideOffset = MENU_DEFAULT_SLIDE_OFFSET;
113126
self.panGestureSideOffset = 0;
@@ -232,9 +245,9 @@ - (void)switchToViewController:(UIViewController *)viewController
232245
{
233246
if (slideOutAnimation)
234247
{
235-
[UIView animateWithDuration:(slideOutAnimation) ? MENU_SLIDE_ANIMATION_DURATION : 0
248+
[UIView animateWithDuration:(slideOutAnimation) ? self.menuRevealAnimationDuration : 0
236249
delay:0
237-
options:UIViewAnimationOptionCurveEaseOut
250+
options:self.menuRevealAnimationOption
238251
animations:^{
239252
CGFloat width = self.horizontalSize;
240253
CGFloat moveLocation = (self.horizontalLocation> 0) ? width : -1*width;
@@ -287,12 +300,12 @@ - (void)popAllAndSwitchToViewController:(UIViewController *)viewController
287300

288301
- (void)closeMenuWithCompletion:(void (^)())completion
289302
{
290-
[self closeMenuWithDuration:MENU_SLIDE_ANIMATION_DURATION andCompletion:completion];
303+
[self closeMenuWithDuration:self.menuRevealAnimationDuration andCompletion:completion];
291304
}
292305

293306
- (void)openMenu:(Menu)menu withCompletion:(void (^)())completion
294307
{
295-
[self openMenu:menu withDuration:MENU_SLIDE_ANIMATION_DURATION andCompletion:completion];
308+
[self openMenu:menu withDuration:self.menuRevealAnimationDuration andCompletion:completion];
296309
}
297310

298311
- (void)toggleLeftMenu
@@ -467,7 +480,7 @@ - (void)openMenu:(Menu)menu withDuration:(float)duration andCompletion:(void (^)
467480

468481
[UIView animateWithDuration:duration
469482
delay:0
470-
options:UIViewAnimationOptionCurveEaseOut
483+
options:self.menuRevealAnimationOption
471484
animations:^{
472485
CGRect rect = self.view.frame;
473486
CGFloat width = self.horizontalSize;
@@ -490,7 +503,7 @@ - (void)closeMenuWithDuration:(float)duration andCompletion:(void (^)())completi
490503

491504
[UIView animateWithDuration:duration
492505
delay:0
493-
options:UIViewAnimationOptionCurveEaseOut
506+
options:self.menuRevealAnimationOption
494507
animations:^{
495508
CGRect rect = self.view.frame;
496509
rect.origin.x = 0;
@@ -647,6 +660,13 @@ - (void)postNotificationWithName:(NSString *)name forMenu:(Menu)menu
647660
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:userInfo];
648661
}
649662

663+
#pragma mark - UIGestureRecognizerDelegate Methods -
664+
665+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
666+
{
667+
return YES;
668+
}
669+
650670
#pragma mark - UINavigationControllerDelegate Methods -
651671

652672
- (void)navigationController:(UINavigationController *)navigationController

0 commit comments

Comments
 (0)