title: How can I create a working interruptible view controller transition on iOS?
body: <p>iOS 10 added a new function for custom animated view controller transitions called
  <a href="https://developer.apple.com/documentation/uikit/uiviewcontrolleranimatedtransitioning/1829434-interruptibleanimator" rel="nofollow noreferrer"><em>interruptibleAnimator(using:)</em></a></p>
  
  <p>Lots of people appear to be using the new function, however by simply implementing their old <em>animateTransition(using:)</em> within the animation block of a UIViewPropertyAnimator in <em>interruptibleAnimator(using:)</em> (see <a href="https://developer.apple.com/videos/play/wwdc2016/216/" rel="nofollow noreferrer">Session 216 from 2016</a>)</p>
  
  <p>However I can't find a single example of someone actually using the interruptible animator for creating interruptible transitions. Everyone seems to support it, but no one actually uses it.</p>
  
  <p>For example, I created a custom transition between two UIViewControllers using a UIPanGestureRecognizer. Both view controllers have a backgroundColor set, and a UIButton in the middle that changes the backgroundColour on touchUpInside.</p>
  
  <p>Now I've implemented the animation simply as:</p>
  
  <ol>
  <li><p>Setup the toViewController.view to be positioned to the
  left/right (depending on the direction needed) of the
  fromViewController.view</p></li>
  <li><p>In the UIViewPropertyAnimator animation block, I slide the
  toViewController.view into view, and the fromViewController.view out
  of view (off screen).</p></li>
  </ol>
  
  <p>Now, during transition, I want to be able to press that UIButton. However, the button press was not called. Odd, this is how the session implied things should work, I setup a custom UIView to be the view of both of my UIViewControllers as follows: </p>
  
  <pre><code>class HitTestView: UIView {
      override func hitTest(_ point: CGPoint, with event: UIEvent?) -&gt; UIView? {
          let view = super.hitTest(point, with: event)
          if view is UIButton {
              print("hit button, point: \(point)")
          }
          return view
      }
  }
  
  class ViewController: UIViewController {
  
       let button = UIButton(type: .custom)
  
       override func loadView() {
           self.view = HitTestView(frame: UIScreen.main.bounds)
       }
      &lt;...&gt;
  }
  </code></pre>
  
  <p>and logged out the <em>func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView?</em> results. The UIButton <em>is</em> being hitTested, however, the buttons action is <em>not called</em>.</p>
  
  <p>Has anyone gotten this working? </p>
  
  <p>Am I thinking about this wrong and are interruptible transitions just to pausing/resuming a transition animation, and not for interaction?</p>
  
  <p>Almost all of iOS11 uses what I believe are interruptible transitions, allowing you to, for example, pull up control centre 50% of the way and interact with it <em>without releasing the control centre pane</em> then sliding it back down. This is exactly what I wish to do.</p>
  
  <p>Thanks in advance! Spent way to long this summer trying to get this working, or finding someone else trying to do the same.</p>