Created
June 10, 2015 04:48
-
-
Save BradB132/255bdfb3d53dcbe77852 to your computer and use it in GitHub Desktop.
ViewControllerTransitionsPart1-3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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