Search code examples
iosswiftcore-animationlayer

How to achieve zoom in effect like Apple News App or Pinterest ios


Today I found out the the zoom in effect in Apple News App and Pinterest App and I wondered how I can achieve similar effect. I read about the blog of Pinterest https://engineering.pinterest.com/blog/behind-pins-building-pinterest-30-ios

and it says

To do this, we used UINavigationControllerDelegate’s animationControllerForOperation method to provide a UIViewControllerAnimatedTransitioning object to perform the transition

and I couldn't figure out what's behind the scene of CBLPinViewTransition of a type UIViewControllerAnimatedTransitioning

It looks like that I may need to programmatically set the zoom-in scale of somehow(I am not sure whether this is possible without the gesture) in the

func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        // Perform the animation
    } 

when I implement the the protocol UIViewControllerAnimatedTransitioning and UIViewControllerTransitioningDelegate as mentioned in Mathew's blog http://mathewsanders.com/animated-transitions-in-swift/

Am I heading to the right direction? Can anyone have any idea about how to implement this.


Solution

  • Yes, that is the right path. In the transition method, take the frame of the original block. Get a snapshot of the view you're transitioning to, and add it to the view at the frame. Then animate its size change to fill the screen.