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 black shadow to left sidebar #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
34 changes: 21 additions & 13 deletions JTRevealSidebarV2/UIViewController+JTRevealSidebarV2.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "UIViewController+JTRevealSidebarV2.h"
#import "UINavigationItem+JTRevealSidebarV2.h"
#import "JTRevealSidebarV2Delegate.h"
#import <QuartzCore/QuartzCore.h>
#import <objc/runtime.h>

@interface UIViewController (JTRevealSidebarV2Private)
Expand Down Expand Up @@ -78,7 +79,7 @@ - (JTRevealedState)revealedState {

- (CGAffineTransform)baseTransform {
CGAffineTransform baseTransform;

return self.view.transform;
switch (self.interfaceOrientation) {
case UIInterfaceOrientationPortrait:
Expand Down Expand Up @@ -122,7 +123,7 @@ - (UIViewController *)selectedViewController {
return self;
}

// Looks like we collasped with the official animationDidStop:finished:context:
// Looks like we collasped with the official animationDidStop:finished:context:
// implementation in the default UITabBarController here, that makes us never
// getting the callback we wanted. So we renamed the callback method here.
- (void)animationDidStop2:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
Expand All @@ -131,9 +132,9 @@ - (void)animationDidStop2:(NSString *)animationID finished:(NSNumber *)finished
UIView *view = [self.view.superview viewWithTag:(int)context];
[view removeFromSuperview];
}

// notify delegate for controller changed state
id <JTRevealSidebarV2Delegate> delegate =
id <JTRevealSidebarV2Delegate> delegate =
[self selectedViewController].navigationItem.revealSidebarDelegate;
if ([delegate respondsToSelector:@selector(didChangeRevealedStateForViewController:)]) {
[delegate didChangeRevealedStateForViewController:self];
Expand All @@ -154,22 +155,29 @@ - (void)revealLeftSidebar:(BOOL)showLeftSidebar {

if (showLeftSidebar) {
[self.view.superview insertSubview:revealedView belowSubview:self.view];

[UIView beginAnimations:@"" context:nil];
// self.view.transform = CGAffineTransformTranslate([self baseTransform], width, 0);

self.view.frame = CGRectOffset(self.view.frame, width, 0);

self.view.layer.masksToBounds = NO;
self.view.layer.shadowRadius = 5;
self.view.layer.shadowOpacity = 1;
self.view.layer.shadowColor = [[UIColor blackColor] CGColor];
self.view.layer.shadowOffset = CGSizeZero;
self.view.layer.shadowPath = [[UIBezierPath bezierPathWithRect:self.view.bounds] CGPath];

} else {
[UIView beginAnimations:@"hideSidebarView" context:(void *)SIDEBAR_VIEW_TAG];
// self.view.transform = CGAffineTransformTranslate([self baseTransform], -width, 0);

self.view.frame = CGRectOffset(self.view.frame, -width, 0);
}

[UIView setAnimationDidStopSelector:@selector(animationDidStop2:finished:context:)];
[UIView setAnimationDelegate:self];

NSLog(@"%@", NSStringFromCGAffineTransform(self.view.transform));


Expand All @@ -179,7 +187,7 @@ - (void)revealLeftSidebar:(BOOL)showLeftSidebar {
- (void)revealRightSidebar:(BOOL)showRightSidebar {

id <JTRevealSidebarV2Delegate> delegate = [self selectedViewController].navigationItem.revealSidebarDelegate;

if ( ! [delegate respondsToSelector:@selector(viewForRightSidebar)]) {
return;
}
Expand All @@ -194,19 +202,19 @@ - (void)revealRightSidebar:(BOOL)showRightSidebar {

[UIView beginAnimations:@"" context:nil];
// self.view.transform = CGAffineTransformTranslate([self baseTransform], -width, 0);

self.view.frame = CGRectOffset(self.view.frame, -width, 0);
} else {
[UIView beginAnimations:@"hideSidebarView" context:(void *)SIDEBAR_VIEW_TAG];
// self.view.transform = CGAffineTransformTranslate([self baseTransform], width, 0);
self.view.frame = CGRectOffset(self.view.frame, width, 0);
}

[UIView setAnimationDidStopSelector:@selector(animationDidStop2:finished:context:)];
[UIView setAnimationDelegate:self];

NSLog(@"%@", NSStringFromCGAffineTransform(self.view.transform));

[UIView commitAnimations];
}

Expand Down