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.
It was build with the following points in mind:
- Left/right OR top/bottom stacking
- Customizable transitions and animations (through layouters and easing functions)
- Pagination
- Realistic physics
- Correct appearance calls
- Customizable interaction area
- Completion blocks and more..
- Started calculating the visible percentage for the root view controller
- Exposed visibleViewControllers array
- Added popViewController:animated:completion: method
- Fixed rotation and autoresizing handling
- Calling didShowViewController: and didHideViewController: delegate methods for root view controller appearance changes
-
Switched to SCScrollView
-
Drops CAMediaTimingFunction in favour of AHEasing for more animation options and control (31 easing functions available ootb with support for creating custom ones through the SCEasingFunctionProtocol)
-
Fixes display link retain cycles
-
Allows content offset animation interruption
-
Various other tweaks and fixes
-
New easing functions examples
- Fixed step navigation methods
- Fixed pagination after bouncing
- Exposed visiblePercentageForViewController: method
- Exposed layouterForPosition: method
- Fixed firstResponder warning
- Fixed duplicate symbols when used together with SCPageViewController
- Renamed UIViewController category methods to avoid conflicts
- Various tweaks and fixes
- Added a new feature called navigation steps which represent a relative position in a view controller at which the stack will paginate/stop while scrolling. Useful for defining multiple steps when folding/unfolding a certain view controller.
- a navigation steps is created using the percentage at which the stack should bounce/paginate (ranges from 0.0 to 1.0) and is assigned on a per viewController basis.
SCStackNavigationStep *step = [SCStackNavigationStep navigationStepWithPercentage:0.5f];
[self.stackViewController registerNavigationSteps:@[step] forViewController:leftViewController];
- the client can also navigate to any navigation step, registered or not, using:
-(void)navigateToStep:(SCStackNavigationStep *)step
inViewController:(UIViewController *)viewController
animated:(BOOL)animated
completion:(void(^)())completion;
- Added option for specifying if the navigation steps are respected when folding, unfolding or both
[self.stackViewController setNavigationContaintType:SCStackViewControllerNavigationContraintTypeForward | SCStackViewControllerNavigationContraintTypeReverse];
- Interface builder support (used in the demo project)
- Better rotation handling
- Added new layouter which resizes the root view controller instead of offsetting it
- Added ability to stack view controllers either on top or below the root view controller
- Exposed minimum and maximum number of touches properties
- Switched run loop modes for better integration with other scroll views
- Integrated MOScrollView for better control over scroll animation and duration
- Added pagedNavigation (exposed continuousNavigation property. Defaults to false). Swiping will bounce at every page and multiple swipes will be required to navigate through more than 1 page
- Added delegate for callbacks when a view controller was shown or hidded and when the Stack's scroll content offset was changed
- Fixed pop animation which now goes through the layouters
- Fixed appearance calls so that they inform the correct view controllers and work while scrolling/tracking.
- Proper reversed stacking implementation
- Fixed parallax layouter to work for the first view controllers
- Added iOS 5.x support
- Added documentation
- Exposed animation duration (defaults to 0.25f)
- Exposed timing function (defaults to kCAMediaTimingFunctionEaseInEaseOut)
- Exposed scroll view bounces property (defaults to YES)
- Exposed scroll indicator visiblity control (defaults to not visible)
- Exposed pagingEnabled property
- Exposed root view controller as readonly
SCStackViewController 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];
- Register layouters
id<SCStackLayouterProtocol> layouter = [[SCParallaxStackLayouter alloc] init];
[stackViewController registerLayouter:layouter forPosition:SCStackViewControllerPositionLeft];
- Set a touch refusal area (optional)
[stackViewController setTouchRefusalArea:[UIBezierPath bezierPathWithRect:CGRectInset(self.view.bounds, 50, 50)]]
- 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 stefan.ceriu@yahoo.com or @stefanceriu.