InterruptibleTransitionAnimation
@available(iOS 10.0, *)
open class InterruptibleTransitionAnimation : InteractiveTransitionAnimation
Use InterruptibleTransitionAnimation to define interactive transitions based on the UIViewPropertyAnimator APIs introduced in iOS 10.
-
Creates an interruptible transition animation based on duration, an animator generator closure and an interaction controller generator closure.
Declaration
Swift
public init(duration: TimeInterval, generateAnimator: @escaping (UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating, generateInteractionController: @escaping () -> PercentDrivenInteractionController?)
Parameters
duration
The total duration of the animation.
generateAnimator
A generator closure to create a
UIViewPropertyAnimator
dynamically.generateInteractionController
A generator closure to create an interaction controller which handles animation progress changes.
-
Creates an interruptible transition animation based on duration and an animator generator closure.
A
UIPercentDrivenInteractiveTransition
is used as interaction controller.Declaration
Swift
public convenience init(duration: TimeInterval, generateAnimator: @escaping (UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating)
Parameters
duration
The total duration of the animation.
generateAnimator
A generator closure to create a
UIViewPropertyAnimator
dynamically.
-
Generates an interruptible animator based on the transitionContext. It further adds a completion block to the animator to ensure it is deallocated once the transition is finished.
This code is called once per transition to generate the interruptible animator which is reused in subsequent calls of
interruptibeAnimator(using:)
.Declaration
Swift
open func generateInterruptibleAnimator(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating
Parameters
transitionContext
The context in which the transition is performed.
-
See UIViewControllerAnimatedTransitioning for further information.
This method simply calls
startAnimation()
on the interruptible animator.Declaration
Swift
open override func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
Parameters
transitionContext
The context in which the transition is performed.
-
See UIViewControllerAnimatedTransitioning for further information.
This method returns an already generated interruptible animator, if present. Otherwise it generates a new one using
generateInterruptibleAnimator(using:)
.Declaration
Swift
open func interruptibleAnimator(using transitionContext: UIViewControllerContextTransitioning ) -> UIViewImplicitlyAnimating
Parameters
transitionContext
The context in which the transition is performed.