ios - 如何实现类似Apple News App或Pinterest ios的放大效果

标签 ios swift core-animation layer

今天我发现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

而且我无法弄清楚UIViewControllerAnimatedTransitioning 类型的CBLPinViewTransition 的幕后是什么

看起来我可能需要以编程方式在

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

当我实现协议(protocol) UIViewControllerAnimatedTransitioningUIViewControllerTransitioningDelegate 时,如 Mathew 的博客中所述 http://mathewsanders.com/animated-transitions-in-swift/

我的方向是否正确?任何人都可以知道如何实现这一点。

最佳答案

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

关于ios - 如何实现类似Apple News App或Pinterest ios的放大效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36961778/

相关文章:

objective-c - 限制多个 UITextField 的长度

objective-c - touchesBegan 在 uiresponder 的子类中被忽略

arrays - 将 .csv 数据导入数组

ios - 重复忙圈动画

ios - UIWebView 第一次请求太慢

swift - 无法在标签栏 Swift 2 中将文本添加到 ListView

iOS 10 打开设置崩溃

iphone - 尽管设置了contentsScale,为什么CAShapeLayer仍然太大?

ios - 缩放 super 层时如何不缩放 CATextLayers

ios - MasterViewController (UISplitViewController) 上 UISearchBar 下的 UITableView