使用 ContainerViewController,如何在子 ViewController 之间添加交互式动画? [英] Using a ContainerViewController, how do i add an interactive animation between child ViewControllers?

查看:13
本文介绍了使用 ContainerViewController,如何在子 ViewController 之间添加交互式动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个自定义的 NavigationViewController,其中导航栏是顶部的可滑动条,用于控制转换(想想 UITabBarController 但滑动手势不是按钮).这是一个快速模型.我为粗鲁道歉

I'm trying to create a customized NavigationViewController where the Navigation bar is a swipeable bar at the top that controls the transitions (think UITabBarController but with swipe gestures not buttons). Here is a quick mockup. I apologize for the crudeness

我将标题栏设置为 ScrollView.我已经能够使用 scrollViewDidScroll 方法成功检测滚动量.所以我把标题栏部分装好了.我现在需要在 scrollViewDidScroll 方法中实现过渡移动.

I have the header bar set up as a ScrollView. I have been able to successfully detect the scroll amount using the scrollViewDidScroll method. So I have the header bar portion rigged up. I now need to implement the transition movement in the scrollViewDidScroll method.

我查阅了 Apple 文档,了解如何将视图控制器相互嵌入,但这并没有真正帮助解释如何做到这一点.文档提到调用 addChildViewController: 方法和一堆其他方法,如果我想让 viewControllers 消失并立即重新出现,这些方法很好,但在这种情况下,我发现很难以交互方式进行.

I have looked up the Apple Documentation on how to embed view controllers inside each other but it hasn't really helped explain how to do this. The documentation mentions calling the addChildViewController: method and a bunch of other methods which are fine if I want to make the viewControllers disappear and reappear instantly, but in this scenario I'm finding hard to do it interactively.

我是否创建当前 VC 的快照然后移动它?但是我到底在移动什么?例如,在图片中,我是否将整个 RedVC 向左移动?但是,如果 BlueVC 从框架外开始移动,我该如何获取它的快照?如果我想在 BlueVC 中异步加载图像怎么办?在 BlueVC 捕捉到位之前,我是否必须使用带有占位符的占位符快照?

Do I create a snapshot of the current VC and then move it? But then what exactly am I moving? In the picture for example, am I moving the entire RedVC's to the left? But then how do I get a snapshot of the BlueVC if it starts moving from outside the frame? What if I want to load in images asynchronously in the BlueVC? Will I have to use a placeholder snapshot with placeholders until the BlueVC snaps in place?

这一切都变得如此复杂......我已经单独完成了这样的事情(快照、自定义 VC 转换等),但我不太习惯在这样的情况下将它们全部结合起来.我敢肯定,如果有足够的时间,我可以通过某种方式进行改进,但我想了解什么是最好、最干净的方法.

This is all becoming so convoluted... I've done stuff like this separately (snapshots, custom VC transitions, etc..) but I'm not comfortable enough in combining them all in a case like this. I'm sure I can hack up some way given enough time, but I want to learn what is the best, cleanest way.

感谢您的帮助!谢谢.

接受@MilanNosáľ的回答后

我最终使用了 这个 repo 中链接的他的框架.它还不是交互式的,但我可以使用他们非常慷慨地为我做的事情来弄清楚其余的.我希望我可以在这里发布完整的代码,但这不是很实用.回购将无限期保留,供未来的 SO 旅行者使用.

I ended up using his framework as linked in this repo. It's not interactive yet, but I can figure out the rest using what they've very graciously done for me. I wish I could post the full code here, but that's not very practical. The repo will remain up indefinitely for future SO travelers.

推荐答案

我最初将米兰的答案选为问题的最终答案.但是,在过去几周我尝试着手处理它之后,在他很多的帮助下,我们都同意将他的框架集成到可用于此任务的格式中太困难了.我现在正在为下面的 ViewControllers 使用 UIScrollView,并让上面的 HeaderView(带有标签的东西)控制下面的 ViewControllers 的滚动视图.

I initially had Milan's answer selected as the final answer to the question. But, after I tried working on it for the past few weeks, with a lot of help from him, we both agreed it was too difficult to integrate his framework into a format useable for this task. I'm now working on just using a UIScrollView for the ViewControllers below, and let the HeaderView above (the thing with the labels) control the ViewControllers' scroll view below.

这篇关于使用 ContainerViewController,如何在子 ViewController 之间添加交互式动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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