Skip to content

Instantly share code, notes, and snippets.

@BradB132
Created June 10, 2015 04:48
Show Gist options
  • Save BradB132/255bdfb3d53dcbe77852 to your computer and use it in GitHub Desktop.
Save BradB132/255bdfb3d53dcbe77852 to your computer and use it in GitHub Desktop.
ViewControllerTransitionsPart1-3
#define kTransitionDuration 0.35
// ...
#pragma mark - UIViewControllerAnimatedTransitioning
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext
{
return kTransitionDuration;
}
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
{
//fade the new view in
UIViewController* toController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIViewController* fromController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIView* container = [transitionContext containerView];
toController.view.alpha = 0.0f;
[container addSubview:toController.view];
[UIView animateWithDuration:kTransitionDuration animations:^{
toController.view.alpha = 1.0f;
} completion:^(BOOL finished){
[fromController.view removeFromSuperview];
[transitionContext completeTransition:finished];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment