Hi! I am using this library with default animation. I only set the parameters isHeroEnabled and heroID.
Everything is ok, but I need to do a different animation for "pop" transition. How can I do?
Thank you for your help!
Sorry. This is my code
self.navigationController?.isHeroEnabled = true
self.navigationController?.heroNavigationAnimationType = .selectBy(presenting:.zoomOut, dismissing:.fade)
let previewPoiViewController = PreviewPoiViewController()
previewPoiViewController.isHeroEnabled = true
previewPoiViewController.poi = self.pois[indexPath.row]
self.navigationController?.pushViewController(previewPoiViewController, animated: true)
But .selectBy(presenting:.zoomOut, dismissing:.fade) not working.
Where am I wrong?
And I cannot change heroNavigationAnimationType ...
If I set it with any value, the animation doesn't change.
you should set your UINavigationControllerDelegate to something that will return a custom HeroTransition navigation delegate.
fileprivate let heroTransition = HeroTransition()
self.navigationController?.delegate = self
self.navigationController?.heroNavigationAnimationType = .autoReverse(presenting: .slide(direction: .left))
extension MyViewController: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning)
-> UIViewControllerInteractiveTransitioning? {
return heroTransition.navigationController(navigationController, interactionControllerFor: animationController)
}
func navigationController(_ navigationController: UINavigationController,
animationControllerFor operation: UINavigationControllerOperation,
from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return heroTransition.navigationController(navigationController, animationControllerFor: operation, from: fromVC, to: toVC)
}
}
They must have updated this because
navigationController.hero.navigationAnimationType = .selectBy(presenting: .zoomSlide(direction: .right), dismissing:.zoomSlide(direction: .left))
Works as expected
Most helpful comment
you should set your
UINavigationControllerDelegateto something that will return a customHeroTransitionnavigation delegate.1. define your transition
2. set your navigation controller's delegate
3. implement delegate mothods