Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is <a href="http://www.teehanlax.com/blog/custom-uiviewcontroller-transitions/" rel="nofollow">some post on a blog I found</a> that explains Apple new Transitioning API on iOS 7, go through it, read it. </p> <hr> <p>In short lines, here are the steps</p> <p><strong><em>1 - Set a transition delegate on a controller</em></strong></p> <p>There are 3 types of transitions you might want to customise :</p> <ul> <li><code>UINavigationController</code> push &amp; pop transitions</li> <li><code>UItabBarController</code> tab changed transitions</li> <li>any modal presentation with <code>presentViewController:animated</code></li> </ul> <p>Each of these 3 cases offers its own 'transition delegate' protocol :</p> <ul> <li><code>UINavigationControllerDelegate</code></li> <li><code>UITabBarControllerDelegate</code></li> <li><code>UIViewControllerTransitioningDelegate</code> </li> </ul> <p>When, from somewhere in your code, you use the methods for presentation :</p> <ul> <li><code>pushViewController:animated:</code> or <code>popViewControllerAnimated:</code></li> <li><code>setViewControllers:animated:</code></li> <li><code>presentViewController:animated</code></li> </ul> <p>Then, these delegates asks for what I call an 'animator' if an animation is required.</p> <p>What I'm calling an 'animator' is an object conforming to protocol <code>&lt;UIViewControllerAnimatedTransitioning&gt;</code> (or <code>&lt;UIViewControllerInteractiveTransitioning&gt;</code> in case of interactive transition, like gesture driven interactions). This decouples the animation from your <code>UIViewControllers</code> (which might already have plenty of code inside)</p> <p><strong><em>2 - Write the 'animator'</em></strong></p> <p>This is the object responsible for animating transition. This can be a viewController, or a completely new NSObject.</p> <p>In case of a UINavigationController, you could define different animators for push and pop operation.</p> <p><strong><em>3 - add the properties you need for your animation into your animator, and code the animation</em></strong></p> <p>The 'animator' might implement different protocols, depending on which transition you're trying to customise. In case of non interactive animations, these are the methods :</p> <ul> <li><p><code>- (NSTimeInterval)transitionDuration:(id&lt;UIViewControllerContextTransitioning&gt;)transitionContext</code> : define the duration of animation</p></li> <li><p><code>- (void)animateTransition:(id&lt;UIViewControllerContextTransitioning&gt;)transitionContext</code> this is where the beef goes. See the example code in link above, </p></li> <li><p><code>- (void)animationEnded:(BOOL)transitionCompleted</code> for any clean-up after your animation was played.</p></li> </ul> <hr> <p>In your case, you might want to add some 'origin' and 'target' <code>UIView</code> properties in your animator class (as weak properties of course !)</p> <p>Then, when you detect 'which' view was tapped by user. (in your <code>UITableVIewDelegate</code> or <code>UICollectionViewDelegate</code> didSelect methods), you tell your animator so that it can animate with THAT specific frame, then call the 'push', 'pop' or 'presentViewController' , depending on your navigation logic.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload