自定义过渡可以使用标准容器轻松工作,同时呈现模态视图控制器.但是使用完全自定义容器的自定义转换呢?
我想将UIViewControllerContextTransitioning协议与我的自定义容器一起使用,并利用转换和交互式转换.
在UIViewControllerContextTransitioning我读到的头文件的注释中:
// The UIViewControllerContextTransitioning protocol can be adopted by custom
// container controllers. It is purposely general to cover more complex
// transitions than the system currently supports.
Run Code Online (Sandbox Code Playgroud)
但我无法理解如何创建一个Context Transitioning并启动所有自定义转换过程.
这很有可能!
看看这个SO答案.
您只需要创建一个符合UIViewControllerContextTransitioning协议的viewController并使用ViewController Containment API(addChildViewController:,willMoveToParentViewController:等等).
如果要启动自定义转换,只需在transitionController上调用[animateTransition]方法即可.从那时起,它与Apple提供的API相同.
使用Transitioning API使您的自定义容器适合.
实际上,iOS7中引入的所有新协议(UIViewControllerContextTransitioning等)并不是真正需要实现自己的完全自定义的containerViewController.它只是提供了一个整洁的类关系和方法池.但是您可以自己编写所有内容,而不需要使用任何私有API.ViewController Containment(在iOS5中引入)是您完成这项工作所需的全部内容.
我只是尝试过试一试,它甚至可以使用交互式过渡.
如果您需要一些示例代码,请告诉我,我会提供一些:)
编辑
顺便说一下,Facebook和Instagram for iOS正在创建他们的导航概念.你可以滚动这些应用程序中的NavigationBar,当一个新的ViewController被"推"时,NavigationBar似乎在推送过程中被重置.
具有讽刺意味的是,我在一个月前在StackOverflow上问了完全相同的问题:D
而我才意识到自己已经回答了:)
祝你今天愉快 !
| 归档时间: |
|
| 查看次数: |
1688 次 |
| 最近记录: |