iOS-7-Custom-ModalViewController-Transitions
iOS-7-Custom-ModalViewController-Transitions copied to clipboard
Sample project implementing new custom ModalViewController Transitions on iOS 7.
iOS-7-Custom-ModalViewController-Transitions
Sample project implementing new custom ModalViewController Transitions on iOS 7. We have a UIViewController view as a subview/modal on top of another UIViewController view, such as that the subview/modal should be transparent and whatever components are added to the subview should be visible. We decided not to use a segue in our Storyboard.

Requirements
Our sample requires iOS 7 and above.
Installation
- Add
TransitionDelegate.h/mandAnimatedTransitioning.h/mto your project (4 files total). Or to drag a folder calledTransition Delegatewith files inside to your project. - In your
RootViewController.mfile, include with#import "TransitionDelegate"and do the following to instantiate and to present a modal view controller with a clearColor in background.
#import "RootViewController.h"
#import "TransitionDelegate.h"
@interface RootViewController ()
@property (nonatomic, strong) TransitionDelegate *transitionController;
@end
@implementation RootViewController
@synthesize transitionController;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.transitionController = [[TransitionDelegate alloc] init];
}
- (IBAction)displaySecondVC:(id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
vc.view.backgroundColor = [UIColor clearColor];
[vc setTransitioningDelegate:transitionController];
vc.modalPresentationStyle= UIModalPresentationCustom;
[self presentViewController:vc animated:YES completion:nil];
}
@end
Usage
Check out the sample Xcode project in CustomTransitionExample.
Recommendations
This is outlined in the 'Custom Transitions Using View Controllers' talk from WWDC 2013, which also covers how to implement your own transition delegate.
Contact
@sharpimedia or @hightechartist on Twitter
License
Copyright © 2013 Blanche Faur.
This code is distributed under the terms and conditions of the MIT License.