JKHImageZoomTransition is a simple Swift 3 framework that allows you to add Apple-esque view controller transitions whether its presented within a UINavigationController stack or presented modally.
See the example below:
You can quickly start using JKHImageZoomTransition by adding the line below to your project's Podfile
pod "JKHImageZoomTransition"
The source is contained inside the Pod/Classes
folder. Simply drag these classes into your project's directory.
Your source and destination view controllers need to implement this protocol to facilitate the transition. The protocol is as follows:
optional func transitionFromImageView() -> UIImageView
optional func transitionToImageView() -> UIImageView
optional func transitionDidFinish(completed: Bool, finalImage: UIImage)
transitionFromImageView
is called to fetch the UIImageView from the source view controller
transitionToImageView
is called to fetch the UIImageView from the destination view controller
transitionDidFinish
is called when the view controller transition ends on the destination view controller
To use custom view controller transitions inside a UINavigationController as opposed to the standard push and pull transitions, you must first set the navigation controller delegate in your UINavigationController. JKHNavigationControllerDelegate
is conveniently provided to override the standard transitions.
To use custom view controller transitions modally you must:
-
Set the
transitioningDelegate
property in your "from" view controller toself
. -
Implement the
UIViewControllerTransitioningDelegate
protocol in your "from" view controller to specify which animation controller to use. (Please seeJKHCorgiCollectionViewController.swift
as an example) -
You'll want to implement the following methods: - animationControllerForPresentedController - animationControllerForPresentedController
-
Return a new instance of the
JKHImageZoomAnimationController
with your desired parameters:Note:
JKHImageZoomType
is an enum that specifies whether you want to use a zoom in or zoom out transition.
- iOS 8.0 or higher
- Transform for destination view controller now calculated correctly
- TabBars now animate independently when transitioning to UITabBarControllers
- Swift 3 support
- First pre-release.
Joon Ki Hong jhong70@icloud.com
JKHImageZoomTransition is available under the MIT license.