Skip to content

psholtz/KBFoldingView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KBFoldingView

http://farm8.staticflickr.com/7374/8729195157_ec0c72f651_o.gif

KBFoldingView is an easy-to-use category on UIView that facilitates stunning onscreen transitions between views on iOS.

KBFoldingView draws much of its inspiration from the very excellent XYOrgami by xyfeng on github.

Example Usage

The folding category works by invoking the category method on the "source" view (or the view which is initially displayed on screen), and passing as an argument the "destination" view which is to be rendered onscreen after the view transition has terminated.

The basic idea is something like this:

UIView *srcView = ...;
UIView *destView = ...;

[srcView showFoldingView:destView];

While the API will work as indicated above, it should be noted that what is described above is an (extremely) simple "default" implementation: the number of folds in the transition is hard-coded, the duration of the fold is hard-coded and the direction from the destination view appears onscreen is hard-coded.

Nearly all users will want the flexibility to configure all three of these parameters dynamically, and will thus want to use the more robust versions of these APIs where these values can be configured manually:

[srcView showFoldingView:destView
                   folds:folds
               direction:direction
                duration:duration
            onCompletion:completionBlock];

The duration variable is of type NSTimeInterval, direction and folds are both of type NSUInteger, and the signature of the optional completion block is (void (^)(BOOL completed)). Users can set the compiler flag kbFoldingViewUseBoundsChecking to TRUE if they want to prevent non-sensical values for duration, direction and fold from being passed into the API.

Support

KBFoldingView is designed to run on all iOS devices (iPhone4, iPhone5 and iPad), and on all iOS versions from 5.0 and up.

KBFoldingView is designed to be used on ARC-enabled projects.

KBFoldingView requires linking with the QuartzCore Framework.

License

The code is distributed under the terms and conditions of the MIT license.

Change Log

Version 1.1 @ February 11, 2015

  • Support for iOS7, iOS8.
  • Other minor updates.

Version 1.0 @ May 11, 2013

  • Initial Release.

Acknowledgements

I undertook this project largely as an attempt to understand more thoroughly how 3D transformations work in CoreGraphics and Quartz. Much of the inspiration for this code comes from the very excellent XYOrgami by xyfeng. What I've done here amounts to little more than a refactoring of his code to improve its readability, maintainability and integrability, as well as adding a few minor features of my own that I found useful. The PaperFold-for-iOS and PaperFoldMenuController projects by honcheng are also great learning resources.

About

KBFoldingView is an easy-to-use category on UIView that facilitates stunning, paper-folding transitions between views on iOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published