如何实现像Apple News App或Pinterest一样的放大效果ios

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

今天发现了Apple News App和Pinterest App中的放大效果,想知道如何实现类似的效果。我阅读了 Pinterest 的博客 https://engineering.pinterest.com/blog/behind-pins-building-pinterest-30-ios

它说

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

而且我无法弄清楚 CBLPinViewTransition 类型 UIViewControllerAnimatedTransitioning

的幕后情况

看来我可能需要以某种方式在

中以某种方式设置放大比例(我不确定如果没有手势是否可行)
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        // Perform the animation
    } 

当我实施 Mathew 的博客 http://mathewsanders.com/animated-transitions-in-swift/

中提到的协议 UIViewControllerAnimatedTransitioningUIViewControllerTransitioningDelegate

我的方向对吗?任何人都可以知道如何实现这一点。

是的,这是正确的道路。在过渡方法中,取原始块的帧。获取您要转换到的视图的快照,并将其添加到框架中的视图。然后动画其大小变化以填满屏幕。