title: Custom unwind segue animation
body: <p>I have the following set up:</p>
  
  <p><img src="https://i.stack.imgur.com/Gr0tK.png" alt="Setup idea"></p>
  
  <p>The red controller has a method </p>
  
  <pre><code>- (IBAction)unwindToRed:(UISegue *)segue
  </code></pre>
  
  <p>and a </p>
  
  <pre><code>- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier
  </code></pre>
  
  <p>which returns a custom segue for this event.</p>
  
  <p>In my custom segue I have the following in the perform code:</p>
  
  <pre><code>- (void)perform
  {
      // Just helpers to get the controllers from the segue
      UIViewController *destination = self.destinationViewController;
      UIViewController *source = self.sourceViewController;
  
      // Setting transitioning delegate for custom transitions
      destination.transitioningDelegate = self;
      source.transitioningDelegate = self;
  
      destination.modalTransitionStyle = UIModalPresentationCustom;
      source.modalPresentationStyle = UIModalPresentationCurrentContext;
  
      // When I am transitioning to a new one
      if(!self.reversed)
      {
          [source presentViewController:destination animated:YES completion:nil];
      }
      // Or reversing from a current one
      else
      {
          [source dismissViewControllerAnimated:YES completion:nil];
      }
  }
  </code></pre>
  
  <p>As you can see I have setup a transition delegate which which in turn calls </p>
  
  <pre><code>- (void)animateTransition:(id&lt;UIViewControllerContextTransitioning&gt;)transitionContext
  </code></pre>
  
  <p>on an animation controller where I apply my custom animation. But now when I tap Unwind to Red on the yellow view, it only "unwinds" to its parent. (e.g the blue one). </p>
  
  <p>When I leave the custom segue out of the equation it works just fine. It goes al the way to the top. </p>
  
  <p>Now I think this has to do with the </p>
  
  <pre><code>[source dismissViewControllerAnimated:YES];
  </code></pre>
  
  <p>line, since that usually just goes "one up" my question is I think, what should I call there so it goes all the way up to red when needed? Yellow is a modal overlay. So "pop too root" would not work.</p>