Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'mst/master'

  • Loading branch information...
commit b932becb7b8e707012f2f0dacca64ada312534f8 2 parents fd6210b + 600c836
@steipete authored
View
3  PSStackedView/PSStackedViewController.h
@@ -111,6 +111,9 @@ enum {
/// Property to disable bounces
@property(nonatomic, assign) BOOL enableBounces;
+/// Property to disable shadows
+@property(nonatomic, assign) BOOL enableShadows;
+
/// left inset thats always visible. Defaults to 60.
@property(nonatomic, assign) NSUInteger leftInset;
/// animate setting of the left inset that is always visible
View
75 PSStackedView/PSStackedViewController.m
@@ -39,7 +39,8 @@ @interface PSStackedViewController() <UIGestureRecognizerDelegate> {
unsigned int delegateWillInsertViewController:1;
unsigned int delegateDidInsertViewController:1;
unsigned int delegateWillRemoveViewController:1;
- unsigned int delegateDidRemoveViewController:1;
+ unsigned int delegateDidRemoveViewController:1;
+ unsigned int delegateDidPanViewController:1;
}delegateFlags_;
}
@property(nonatomic, strong) UIViewController *rootViewController;
@@ -60,6 +61,7 @@ @implementation PSStackedViewController
@synthesize delegate = delegate_;
@synthesize reduceAnimations = reduceAnimations_;
@synthesize enableBounces = enableBounces_;
+@synthesize enableShadows = enableShadows_;
@dynamic firstVisibleIndex;
#ifdef ALLOW_SWIZZLING_NAVIGATIONCONTROLLER
@@ -90,6 +92,7 @@ - (id)initWithRootViewController:(UIViewController *)rootViewController; {
[self.view addGestureRecognizer:panRecognizer];
self.panRecognizer = panRecognizer;
enableBounces_ = YES;
+ enableShadows_ = YES;
#ifdef ALLOW_SWIZZLING_NAVIGATIONCONTROLLER
@@ -123,6 +126,7 @@ - (void)setDelegate:(id<PSStackedViewDelegate>)delegate {
delegateFlags_.delegateDidInsertViewController = [delegate respondsToSelector:@selector(stackedView:didInsertViewController:)];
delegateFlags_.delegateWillRemoveViewController = [delegate respondsToSelector:@selector(stackedView:willRemoveViewController:)];
delegateFlags_.delegateDidRemoveViewController = [delegate respondsToSelector:@selector(stackedView:didRemoveViewController:)];
+ delegateFlags_.delegateDidPanViewController = [delegate respondsToSelector:@selector(stackedView:didPanViewController:byOffset:)];
}
}
@@ -150,6 +154,12 @@ - (void)delegateDidRemoveViewController:(UIViewController *)viewController {
}
}
+- (void)delegateDidPanViewController:(UIViewController *)viewController byOffset:(NSInteger)offset {
+ if (delegateFlags_.delegateDidPanViewController) {
+ [self.delegate stackedView:self didPanViewController:viewController byOffset:offset];
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - Private Helpers
@@ -551,35 +561,37 @@ - (CGFloat)overlapRatio {
// updates view containers
- (void)updateViewControllerMasksAndShadow {
- // only one!
- if ([self.viewControllers count] == 1) {
- // [[self firstViewController].containerView addMaskToCorners:UIRectCornerAllCorners];
- self.firstViewController.containerView.shadow = PSSVSideLeft | PSSVSideRight;
- }else {
- // rounded corners on first and last controller
- [self.viewControllers enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- UIViewController *vc = (UIViewController *)obj;
- if (idx == 0) {
- //[vc.containerView addMaskToCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft];
- }else if(idx == [self.viewControllers count]-1) {
- // [vc.containerView addMaskToCorners:UIRectCornerBottomRight | UIRectCornerTopRight];
- vc.containerView.shadow = PSSVSideLeft | PSSVSideRight;
- }else {
- // [vc.containerView removeMask];
- vc.containerView.shadow = PSSVSideLeft | PSSVSideRight;
+ if (enableShadows_ == YES) {
+ // only one!
+ if ([self.viewControllers count] == 1) {
+ // [[self firstViewController].containerView addMaskToCorners:UIRectCornerAllCorners];
+ self.firstViewController.containerView.shadow = PSSVSideLeft | PSSVSideRight;
+ }else {
+ // rounded corners on first and last controller
+ [self.viewControllers enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+ UIViewController *vc = (UIViewController *)obj;
+ if (idx == 0) {
+ //[vc.containerView addMaskToCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft];
+ }else if(idx == [self.viewControllers count]-1) {
+ // [vc.containerView addMaskToCorners:UIRectCornerBottomRight | UIRectCornerTopRight];
+ vc.containerView.shadow = PSSVSideLeft | PSSVSideRight;
+ }else {
+ // [vc.containerView removeMask];
+ vc.containerView.shadow = PSSVSideLeft | PSSVSideRight;
+ }
+ }];
+ }
+
+ // update alpha mask
+ CGFloat overlapRatio = [self overlapRatio];
+ UIViewController *overlappedVC = [self overlappedViewController];
+ overlappedVC.containerView.darkRatio = MIN(overlapRatio, 1.f)/kAlphaReductRatio;
+
+ // reset alpha ratio everywhere else
+ for (UIViewController *vc in self.viewControllers) {
+ if (vc != overlappedVC) {
+ vc.containerView.darkRatio = 0.0f;
}
- }];
- }
-
- // update alpha mask
- CGFloat overlapRatio = [self overlapRatio];
- UIViewController *overlappedVC = [self overlappedViewController];
- overlappedVC.containerView.darkRatio = MIN(overlapRatio, 1.f)/kAlphaReductRatio;
-
- // reset alpha ratio everywhere else
- for (UIViewController *vc in self.viewControllers) {
- if (vc != overlappedVC) {
- vc.containerView.darkRatio = 0.0f;
}
}
}
@@ -654,6 +666,11 @@ - (void)stopStackAnimation {
- (void)moveStackWithOffset:(NSInteger)offset animated:(BOOL)animated userDragging:(BOOL)userDragging {
PSSVLog(@"moving stack on %d pixels (animated:%d, decellerating:%d)", offset, animated, userDragging);
+ // let the delegate know the user is moving the stack
+ if (self.delegate && userDragging) {
+ [self delegateDidPanViewController:self.topViewController byOffset:offset];
+ }
+
[self stopStackAnimation];
[UIView animateWithDuration:animated ? kPSSVStackAnimationDuration : 0.f delay:0.f options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:^{
View
3  PSStackedView/PSStackedViewDelegate.h
@@ -26,4 +26,7 @@
/// viewController has been removed
- (void)stackedView:(PSStackedViewController *)stackedView didRemoveViewController:(UIViewController *)viewController;
+/// viewController has been panned
+- (void)stackedView:(PSStackedViewController *)stackedView didPanViewController:(UIViewController *)viewController byOffset:(NSInteger)offset;
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.