I have a subclass of UIViewControllerAnimatingTransitioning which defines an animations in a method animateTransitioning(using:) with UIView.animate(withDuration: 1) and second one UIView.animate(withDuration: 2, delay: 0.5, options: .curveEaseIn). The UIViewControllerAnimatingTransitioning requires a second method which is transitionDuration(using:) which should return a duration.
How duration defined in transitionDuration(using:) impact the duration defined in UIView.animation(withDuration)?
According to the documentation provided by Apple for the
transitionDuration(using:)method here, the duration you return is used to synchronize other potential animations and "actions".In your scenario where there are two different
UIView.animateblocks, you should return the time it takes for the longest animation to complete. Below is the explanation on how to calculate this. Assume both animations start att = 0, wheretis time in seconds.Since the animation that has the maximum total time is the second animation, you should return
2.5attransitionDuration(using:).It should also be noted that setting the animation duration correctly does not automatically complete the transition after the duration. You must still invoke the
completeTransition(_:)of theUIViewControllerContextTransitioningobject you receive atanimateTransition(using:).Hope I was able to give you some insight!