如何从 UICollectionView 过渡到 UIViewController,如 Pinterest/Evernote [英] How to transition from UICollectionView to UIViewController like Pinterest/Evernote

查看:21
本文介绍了如何从 UICollectionView 过渡到 UIViewController,如 Pinterest/Evernote的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UICollectionView,当一个项目被选中时,我希望它能够以动画方式全屏显示.所以它会从单元格的大小过渡到全屏并成为一个 UIViewController.Pinterest 和 Evernote 都有这种行为,点击单元格会将单元格转换为全屏视图控制器.

有什么例子可以说明这是如何做到的吗?我搜索了几个项目,但没有找到任何关于将单元格转换为全屏视图控制器的说明.

Pinterest 在这里讨论它:

还有这个:

https://itunes.apple.com/app/mei-tu-sou-sou-wan-zhuan-wei/id781146829?mt=8

<小时>

我在几天前创建了这个 repo.使用 Swift,除了一些小问题,我几乎完成了这个过渡,这是我第一个基于 Swift 的演示项目.但是不难理解,如果你不是 iOS 开发的新手,而且你会学习 Swift BTW.我会完成它并稍后修复错误.

在实际项目中,它比演示项目更复杂,但有了它,也许您就知道如何实现这种过渡了.

祝你好运.

I have a UICollectionView and when an item is selected, I'd like it to animate full screen. So it would transition from the size of the cell to full screen and become a UIViewController. Pinterest and Evernote both have this behavior where tapping on a cell transitions the cell into a full screen view controller.

Are there any example of how this is done? I've searched several projects, but haven't found any illustrating on transitioning a cell to full screen view controller.

Pinterest discusses it here: https://medium.com/@Pinterest_Engineering/behind-the-pins-building-pinterest-3-0-for-ios-100f57f6940

解决方案

It's not difficult to implement this transition. Just like the article said, they custom a transition to implement UIViewControllerAnimatedTransitioning protocol, nothing besides. You need to calculate the new size the position which imageView you tapped to animate. That's it.

This our two apps, all implement this similar transition effect by this method above.

https://itunes.apple.com/app/hua-ban-quan-qiu-you-mei-tu/id494813494?mt=8

And this one:

https://itunes.apple.com/app/mei-tu-sou-sou-wan-zhuan-wei/id781146829?mt=8


I'd created this repo several days before. And with Swift, I almost finished this transition beside some little issue, this is my first practised demo project based Swift. But it's not hard to understand if you're not freshman in iOS dev and you'd learn Swift BTW. I'll finish it and fix the bugs later.

In real project it's more complex than the demo one, but with that, maybe you'd knew how to achieve this kind of transition.

Good luck.

这篇关于如何从 UICollectionView 过渡到 UIViewController,如 Pinterest/Evernote的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆