如何使用卷页动画在容器 View (即嵌入转场引用的 View Controller )中更改可见 View Controller 以在两者之间进行转换。
最佳答案
两个选项:
UIPageViewController
在containerView中嵌入一个UIPageViewController(参见文档here)。使用UIPageViewControllerTransitionStyle.PageCurl
初始化页面 View Controller ,并使用setViewControllers:direction:animated:completion:
将第一个VC设置为当前嵌入的 View Controller 容器 View 。然后用同样的方法切换到你要显示的新VC。
此选项的优点是提供开箱即用的基于手势的转换,但 UIPageViewController 可能会令人困惑,因此有一些学习曲线。
UIView 转换
更简单的解决方案是使用UIView
方法transitionFromView:toView:duration:options:completion:
。 (请参阅文档 here )。有一个选项可以使用卷页过渡。有一点复杂的是,您的两个 View 由其他 View Controller 管理,因此您还需要使用 View Controller 方法 addChildViewController:
、didMoveToParentViewController
、willMoveToParentViewController
和 removeFromParentViewController
。文档here对此进行了描述。 (在“实现自定义容器 View Controller ”下)。
关于ios - 更改containerView swift中的可见 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33562258/