Handle shadowPath, shadowOffset, and rotation

This commit is contained in:
Mike Enriquez
2012-04-02 14:57:45 -04:00
parent 23a878b965
commit 8cecf6bc33
2 changed files with 10 additions and 15 deletions

View File

@@ -14,12 +14,11 @@
{
[super viewWillAppear:animated];
self.view.layer.shadowOffset = CGSizeZero;
// shadowPath, shadowOffset, and rotation is handled by ECSlidingViewController.
// You just need to set the opacity, radius, and color.
self.view.layer.shadowOpacity = 0.75f;
self.view.layer.shadowRadius = 10.0f;
self.view.layer.shadowColor = [UIColor blackColor].CGColor;
self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.layer.bounds].CGPath;
self.view.clipsToBounds = NO;
if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
@@ -32,18 +31,6 @@
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
self.view.layer.shadowPath = nil;
self.view.layer.shouldRasterize = YES;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.layer.bounds].CGPath;
self.view.layer.shouldRasterize = NO;
}
- (IBAction)revealMenu:(id)sender
{
[self.slidingViewController anchorTopViewTo:ECRight];

View File

@@ -103,6 +103,8 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset";
[_topViewController.view setAutoresizingMask:self.autoResizeToFillScreen];
[_topViewController.view setFrame:self.view.bounds];
_topViewController.view.layer.shadowOffset = CGSizeZero;
_topViewController.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.layer.bounds].CGPath;
[self.view addSubview:_topViewController.view];
}
@@ -187,6 +189,9 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset";
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
self.topView.layer.shadowPath = nil;
self.topView.layer.shouldRasterize = YES;
if(![self topViewHasFocus]){
[self removeTopViewSnapshot];
}
@@ -195,6 +200,9 @@ NSString *const ECSlidingViewTopDidReset = @"ECSlidingViewTopDidReset";
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
self.topView.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.layer.bounds].CGPath;
self.topView.layer.shouldRasterize = NO;
if(![self topViewHasFocus]){
[self addTopViewSnapshot];
}