- Parallax Push/Pop animator.
- Chaining Push/Pop animator (PushAnimator/PopAnimator).
- Allow custom Push/Pop/PopInteraction Animator.
- Support Edge Pan Gesture & Full Screen Pan Gesture to Pop Interaction.
- Custom duration of animation.
- Support Push Interaction Animator.
To run the example project, clone the repo, and run pod install
from the Example directory first.
STNavigationViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "STNavigationViewController"
- Set up STNavigationViewController is rootViewController in
ApplicationDelegate.swift
let window = UIWindow(frame: UIScreen.main.bounds)
self.window = window
let rootViewController = STNavigationViewController(rootViewController: NormalViewController())
window.rootViewController = rootViewController
window.makeKeyAndVisible()
- Custom animation when transition between 2 controller. - (See example for more information)
override func getPushAnimatedTransitioning(from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning {
switch self.buttonTag {
case 3:
let animator = ParalaxPushAnimator()
// Uncomment line below to edit transition duration of animator
// animator.duration = //<Custom transition animator>
return animator
case 2:
let animator = HideNavigationBarPushAnimator()
// Uncomment line below to edit transition duration of animator
// animator.duration = //<Custom transition animator>
return animator
case 1:
let animator = PushAnimator()
// Uncomment line below to edit transition duration of animator
// animator.duration = //<Custom transition animator>
return animator
default:
return PushAnimator()
}
}
- Other protocol you can custom in STViewController or STViewController's subclasses
func getPushAnimatedTransitioning(from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning {
// You can return your new PUSH animtor here
// Default: return PushAnimator()
return PushAnimator()
}
func getPopAnimatedTransitioning(from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning {
// You can return your new POP animtor here
// Default: return PopAnimator()
return PopAnimator()
}
func getPopInteractionAnimatedTransitioning(from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning {
// You can return your new INTERACTION animtor here
// Default: return InteractionPopAnimator()
return InteractionPopAnimator()
}
- Create new animator
class CustomPushAnimator: PushAnimator { // OR CustomPopAnimator: PopAnimator
override func attackSubviews(from fromVC: STViewController,
to toVC: STViewController,
withContext context: UIViewControllerContextTransitioning) {
// Set view views in context before animation start
}
override func prepareForTransition(from fromVC: STViewController,
to toVC: STViewController,
withContext context: UIViewControllerContextTransitioning) {
// Set up FromViewController and ToViewController position, alpha, etc...
}
override func animatedTransition(from fromVC: STViewController,
to toVC: STViewController,
withContext context: UIViewControllerContextTransitioning) {
// Animation executing.
// Add any transition you want STViewController's view to do
}
override func completion(from fromVC: STViewController,
to toVC: STViewController,
withContext context: UIViewControllerContextTransitioning) {
// Complete animation actions.
}
}
Son Thai, [email protected]
STNavigationViewController is available under the MIT license.
Copyright (c) 2017 Son Thai ([email protected]).
See the LICENSE file for more info.