I want make some change to source code for 17-custom-presentation-controller to make custom transition animation,all my change is in class PopAnimator.
This is my change:
add a new instance variable in PopAnimator to save transitionContext:
You can see the demo above : when user tap the bottom left green view,it present detailsVC,but no animation happened!!! but when dismiss detailsVC,the animation work fine!
I took a brief look at your code, and I did notice that you’ve commented several lines of code that may be the reason. For example:
//transition.reverse = false
Have you tried uncommenting this line, and others like it to see what happens? When it comes to debugging, I would recommend placing a break point, and see what method is called when you dismiss the detailsVC, and then check to see which method is called when presenting it? That would be the first step to identify what the problem is.
I poked it for 20 minutes, but no luck. So kudoz to the one who figures why it works in one case and does not in the other.
@hopy I know this is probably not exactly what you’re looking for, but just in case you don’t know about this: you can use CATransition without all these animated transitioning dancing, just like so:
Good news, though, I’ve figured it would work with UIViewControllerAnimatedTransitioning like this:
create new func animate(transitionContext: UIViewControllerContextTransitioning) {}
move all the code from func animateTransition(using transitionContext: UIViewControllerContextTransitioning) to func animate(transitionContext: UIViewControllerContextTransitioning)
In animateTransition call animate with slight delay like so: