Skip to content

Commit fd9a508

Browse files
committed
- Added option to enable/disable shadow
1 parent 38f6bb5 commit fd9a508

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

SlideMenu/Source/SlideNavigationController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ typedef enum{
4444

4545
@property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController;
4646
@property (nonatomic, assign) BOOL enableSwipeGesture;
47+
@property (nonatomic, assign) BOOL enableShadow;
4748
@property (nonatomic, strong) UIViewController *rightMenu;
4849
@property (nonatomic, strong) UIViewController *leftMenu;
4950
@property (nonatomic, strong) UIBarButtonItem *leftBarButtonItem;

SlideMenu/Source/SlideNavigationController.m

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,17 @@ - (void)setup
9797
self.avoidSwitchingToSameClassViewController = YES;
9898
singletonInstance = self;
9999
self.delegate = self;
100-
101-
self.view.layer.shadowColor = [UIColor darkGrayColor].CGColor;
102-
self.view.layer.shadowRadius = MENU_SHADOW_RADIUS;
103-
self.view.layer.shadowOpacity = MENU_SHADOW_OPACITY;
104-
self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds].CGPath;
105-
self.view.layer.shouldRasterize = YES;
106-
self.view.layer.rasterizationScale = [UIScreen mainScreen].scale;
107-
108-
[self setEnableSwipeGesture:YES];
100+
self.enableShadow = YES;
101+
self.enableSwipeGesture = YES;
109102
}
110103

111104
- (void)viewWillLayoutSubviews
112105
{
113106
[super viewWillLayoutSubviews];
114107

115-
// Update shadow size
116-
self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds].CGPath;
108+
// Update shadow size of enabled
109+
if (self.enableShadow)
110+
self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds].CGPath;
117111
}
118112

119113
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
@@ -292,6 +286,24 @@ - (BOOL)isMenuOpen
292286
return (self.horizontalLocation == 0) ? NO : YES;
293287
}
294288

289+
- (void)setEnableShaddow:(BOOL)enable
290+
{
291+
if (enable)
292+
{
293+
self.view.layer.shadowColor = [UIColor darkGrayColor].CGColor;
294+
self.view.layer.shadowRadius = MENU_SHADOW_RADIUS;
295+
self.view.layer.shadowOpacity = MENU_SHADOW_OPACITY;
296+
self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.bounds].CGPath;
297+
self.view.layer.shouldRasterize = YES;
298+
self.view.layer.rasterizationScale = [UIScreen mainScreen].scale;
299+
}
300+
else
301+
{
302+
self.view.layer.shadowOpacity = 0;
303+
self.view.layer.shadowRadius = 0;
304+
}
305+
}
306+
295307
#pragma mark - Override Methods -
296308

297309
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated

0 commit comments

Comments
 (0)