ZoomDismissalInteractionController
class ZoomDismissalInteractionController : NSObject
A custom interactive dismissal zoom transition for the transition from an ImagePagingCollectionViewController
to an ImageCollectionViewController
when the cell recognizes a pan gesture. It was built to mimic the transition used in the native iPhone Photos app.
This custom animation was documented and explained in complete detail in the links provided below.
-
The context provided to a transtion that has information about the source.
Declaration
Swift
var transitionContext: UIViewControllerContextTransitioning?
-
The animator for the transition.
Declaration
Swift
var animator: UIViewControllerAnimatedTransitioning?
-
The frame of the destination image view.
Declaration
Swift
var fromReferenceImageViewFrame: CGRect?
-
The frame of the source image view.
Declaration
Swift
var toReferenceImageViewFrame: CGRect?
-
The dismissal transition triggered by a panning gesture.
The dismissal only completes if the gesture is released with the image below the starting location and the gesture not moving up the screen. It otherwise cancels and the transition view returns to the source image view.
Declaration
Swift
func didPanWith(gestureRecognizer: UIPanGestureRecognizer)
Parameters
gestureRecognizer
The pan gesture responsible for the dismissal.
-
Calculates the alpha of the backgroud of the source or destination view based on the displacement of the transition view.
Declaration
Swift
func calculateBrackgroundAlphaFor(_ view: UIView, atDelta delta: CGFloat) -> CGFloat
Parameters
view
The view being adjusted. It’s frame is used to measure the displacement.
delta
The current displacement of the image from its origin.
-
Calculate the scale of the transition image based on its displacement from its origin.
Declaration
Swift
func calculateScaleIn(_ view: UIView, atDelta delta: CGFloat) -> CGFloat
Parameters
view
The view being adjusted. It’s frame is used to measure the displacement.
delta
The current displacement of the image from its origin.
-
Called when an interactive transition is initiated. It is used here to prepare the transition controller.
Declaration
Swift
func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning)