ZoomAnimator
class ZoomAnimator : NSObject
A custom zoom animation for the transition from an ImageCollectionViewController
to an
ImagePagingCollectionViewController
when a cell is tapped. It also handles the retraction
transition. 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 delegate being animated from.
Declaration
Swift
weak var fromDelegate: ZoomAnimatorDelegate?
-
The delegate being animated to.
Declaration
Swift
weak var toDelegate: ZoomAnimatorDelegate?
-
A
Boolean
for is the animation is presenting (or retracting)Declaration
Swift
var isPresenting: Bool
-
The image view that is animated from the location of the source image to the destination image.
Declaration
Swift
var transitionImageView: UIImageView?
-
The animation for the zoom in transition.
See also
Declaration
Swift
fileprivate func animateZoomInTransition(using transitionContext: UIViewControllerContextTransitioning)
Parameters
transitionContext
The context provided to a transtion that has information about the source. and destination view controllers.
-
The animation for the zoom out transition.
See also
Declaration
Swift
fileprivate func animateZoomOutTransition(using transitionContext: UIViewControllerContextTransitioning)
Parameters
transitionContext
The context provided to a transtion that has information about the source and destination view controllers.
-
Calculates the final frame size for an image during the zoom-in transition.
Declaration
Swift
private func calculateZoomInImageFrame(image: UIImage, forView view: UIView) -> CGRect
Parameters
image
The image being zoomed.
view
The destination view.
Return Value
A rectangle with the dimensions for the destination of the zoom.
-
The duration of the transition. It is currently set manually to be 0.5 seconds to zoom in (during presentation) and 0.25 to zoom out (not during presentation)
Declaration
Swift
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
Parameters
transitionContext
The context provided to a transtion that has information about the source and destination view controllers.
Return Value
A time interval in seconds.
-
The function called during transition. It is used here to decide which animation to use.
Declaration
Swift
func animateTransition(using transitionContext: UIViewControllerContextTransitioning)