iOS 7 - View Controllers Custom Transitions (CocoaHeads Lyon avril 2014)

iOS 7 - View Controllers Custom Transitions (CocoaHeads Lyon avril 2014)

iOS 7 - Custom Transitions for View Controllers
Pour CocoaHeads Lyon, 10 avril 2014

74079210c61f36dff0a74f24da5727e7?s=128

Vincent Tourraine

April 10, 2014
Tweet

Transcript

  1. View Controller Custom Transitions CocoaHeads Lyon - avril 2014 Vincent

    Tourraine - shazino
  2. Faciliter la personnalisation des transitions entre view controllers (a.k.a. du

    nouveau dans le push/pop)
  3. Navigation Controller delegate - (id<UIViewControllerAnimatedTransitioning>) navigationController:
 (UINavigationController *)navigationController animationControllerForOperation:
 (UINavigationControllerOperation)operation

    fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC { if (operation == UINavigationControllerOperationPush) { return self.animator; } return nil; }
  4. “Animator” object @interface Animator : NSObject 
 <UIViewControllerAnimatedTransitioning> ! @end

  5. - (NSTimeInterval)transitionDuration:
 (id <UIViewControllerContextTransitioning>)transitionContext { return 0.25; } “Animator” object

  6. - (void)animateTransition: (id<UIViewControllerContextTransitioning>)transitionContext { UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; UIViewController

    *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; ! [[transitionContext containerView] addSubview:toVC.view]; toVC.view.alpha = 0; [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{ fromVC.view.transform = CGAffineTransformMakeScale(0.1, 0.1); toVC.view.alpha = 1; } completion:^(BOOL finished) { fromVC.view.transform = CGAffineTransformIdentity; [transitionContext completeTransition:![transitionContext transitionWasCancelled]]; }]; } “Animator” object
  7. Navigation Controller delegate - (id <UIViewControllerInteractiveTransitioning>) navigationController:
 (UINavigationController*)navigationController
 interactionControllerForAnimationController:
 (id

    <UIViewControllerAnimatedTransitioning>)animationController { return self.interactionController; }
  8. Plus d’infos • WWDC 2013 #218
 Custom Transitions using View

    Controllers
 http://asciiwwdc.com/2013/sessions/218 • objc.io #5
 View Controller Transitions
 http://www.objc.io/issue-5/view-controller-transitions.html