A simple way to alternate between UIViewControllers in a UINavigationController stack, via a storyboard-compatible custom segue. (Also compatible with view controllers outside a navigation controller stack)
Based mostly on an example provided by jrwren.
Usage in code is the same as for any other segue. To use with storyboards,
- Drag a new view controller into the storyboard, if necessary.
- Control-drag to wire up a segue as usual.
- In the inspector panel for the segue, choose
Customas the segue's style, and typeRAFlipReplaceSegueas the segue's custom class.
Done!
To use a different built-in transition style while keeping the segue functionality, in RAFlipReplaceSegue.m change UIViewAnimationOptionTransitionFlipFromLeft to one of the following (from the UIView reference):
UIViewAnimationOptionTransitionNoneUIViewAnimationOptionTransitionFlipFromLeftUIViewAnimationOptionTransitionFlipFromRightUIViewAnimationOptionTransitionCurlUpUIViewAnimationOptionTransitionCurlDownUIViewAnimationOptionTransitionCrossDissolveUIViewAnimationOptionTransitionFlipFromTopUIViewAnimationOptionTransitionFlipFromBottom
If you need something more different, read the .m implementation—it's only ~30 lines!
If this helps at all, or is not quite what you need, drop me a tweet @ryanartecona.