SCStackViewController is a container view controller which allows you to stack other view controllers on the top/left/bottom/right of the root and build custom transitions between them while providing correct physics and appearance calls.
SCStackViewController is a little bit from the all the other stack implementations available. It was build with the following points in mind:
- Simple to understand and modify
- Left/right and top/bottom stacking
- Correct physics
- Correct appearance calls
- Customizable transitions
- Pagination
- Customizable interaction area
- Completion blocks for everything
SCStackViewController comes in at just under 500 lines and is build on top of an UIScrollView which gives us the physics we need, content insets for all the 4 positions, callbacks for linking the custom transitions to and easy to build pagination. By overriding the scrollView's shouldReceiveTouch: method we also get the customizable interaction area.
The stack itself relies on layouters to know where to place the stacked controllers at every point. They are build on top of a simple protocol and the demo project contains 6 examples with various effects.
It places the view controllers to their final position and doesn't modify them while dragging.
Reverses the direction used in the plain layouter
It reveals every new controller from beneath the previous one through sliding
Add a nice parallax effect while revealing the stacked controllers
The effect seen in the Google Maps app when opening the drawer
Just something I was playing with.. :)
- Import the stack into your project
#import "SCStackViewController.h"
- Create a new instance
stackViewController = [[SCStackViewController alloc] initWithRootViewController:rootViewController];
- Set a touch refusal area (optional)
[stackViewController setTouchRefusalArea:[UIBezierPath bezierPathWithRect:CGRectInset(self.view.bounds, 50, 50)]]
- Register layouters
id<SCStackLayouterProtocol> layouter = [[SCParallaxStackLayouter alloc] init];
[stackViewController registerLayouter:layouter forPosition:SCStackViewControllerPositionLeft];
- Push view controllers
[self.stackViewController pushViewController:leftViewController
atPosition:SCStackViewControllerPositionLeft
unfold:NO
animated:NO
completion:nil];
######Check out the demo project for more details.
SCStackViewController is released under the MIT License (MIT) (see the LICENSE file)
Any suggestions or improvements are more than welcome. Feel free to contact me at [email protected] or @stefanceriu.





