KNSemiModal Category for iOS

Posted: May 4th, 2012 | Author: | Filed under: iOS | 8 Comments »

UIViewController+KNSemiModal Category

UIViewController+KNSemiModal is an effort to make a replica of semi-modal view with pushed-back stacked animation found in the beautiful Park Guides by National Geographic app. You can see this original semi-modal view below.

The pictures don’t really describe enough the cool factor of the implementation. You can download a short video I recorded to see the effect : demo video (1.3MB, .mov)

Why I do this?

Please read my discussion in a separate blog post. I highlighted some issues with the current implementations of the modal view and how I think it can be better

Drop-in installation

This library (ARC) is designed as a Category to UIViewController so you don’t have to subclass and you can simply drop in any project and it will just work!

Copy 2 category files UIViewController+KNSemiModal to your project and add this import line at the top of your current ViewController file

#import "UIViewController+KNSemiModal.h"

You can prepare your UIView * myView with all the controls and subviews that you need before presenting it with

[self presentSemiModalView:myView]

Another convenient method is presenting a separate ViewController class by calling

[self presentSemiViewController:myOtherViewController]

However, note that this myOtherViewController need to be retained manually by assigning it to a @property or ivar.

TODO

  • Landscape support.
  • Maybe iPad support, it will be quite different though.
  • Fake ivar with Associative References to retain ViewController
  • Subclass branch (anyone can spare the time?)

Source code

https://github.com/kentnguyen/KNSemiModalViewController