Reversed UIViewPropertyAnimator for interactive navigation controller transition

I'm trying to use a

UIViewPropertyAnimator
to drive a custom navigation controller transition. In my implementation, I set up the animation for the push transition, and then set
isReversed = true
on the animator if we actually need a pop transition.


This works fine for non-interactive transitions, and it mostly works for an interactive transition, but when I stop the interactive gesture and call

finish()
or
cancel()
on the interaction controller, it animates to the
.end
or
.start
position of the animation respectively, ignoring the
isReversed
property.


Is there a way to set this up such that when the property animator is reversed it finishes in the reverse direction?


I also have a sample project here that demonstrates the issue: https://github.com/jayrhynas/InteractiveTransitionTest


The relevant code is in DetailTransitionController.swift

Accepted Reply

After submitting a DTS request and discussing with an Apple engineer, we came to the conclusion that this is not possible as is. His recommendation was to manually reverse the logic, either creating 2 separate animators for pushing and popping, or changing the code in the animation blocks based on the direction.


One workaround that techincally works in my case was to set up the animation for popping, and set

isReversed = true
when pushing. Since my app doesn't have an interactive push, this avoids the issue, however it requires reasoning about all your transitions in reverse.

Replies

After submitting a DTS request and discussing with an Apple engineer, we came to the conclusion that this is not possible as is. His recommendation was to manually reverse the logic, either creating 2 separate animators for pushing and popping, or changing the code in the animation blocks based on the direction.


One workaround that techincally works in my case was to set up the animation for popping, and set

isReversed = true
when pushing. Since my app doesn't have an interactive push, this avoids the issue, however it requires reasoning about all your transitions in reverse.