如何在另一个视图控制器的顶部滑动一个视图控制器? [英] How to swipe a View controller over the top of another view controller?

查看:107
本文介绍了如何在另一个视图控制器的顶部滑动一个视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表视图控制器和另一个视图控制器.现在,我的要求是,当我滑动视图控制器时,需要在另一个视图控制器上滑动表格视图控制器一半.我可以显示的图像是这样的:

I have a table view controller and another view controller. Now my requirement is that i need to swipe the table view controller half over the another view controller when i swipe the view controller. The image i can show is like this:

是否可以使用Swipegesture实现此目的.如果可能的话,我该如何在Swift3中做到这一点?

Is it possible to achieve this by using the Swipegesture . If possible how can i do this in Swift3?

推荐答案

虽然有一些库可以为您执行此操作,但是如果您要自己执行此操作,则基本思想是可以创建边缘"手势识别器来启动视图控制器(带有菜单)的自定义演示.它包括:

While there are libraries out there to do this for you, if you are going to do this yourself, the basic idea is that you can create a "swipe from edge" gesture recognizer to initiate a custom presentation of a view controller (that has your menu on it). It consists of:

  • 一个自定义过渡委托(符合UIViewControllerTransitioningDelegate协议),指定要在下一场景的呈现过程中使用的动画控制器和交互控制器(均在下面描述);

  • a custom transitioning delegate (conforming to UIViewControllerTransitioningDelegate protocol) that specifies the animation controller and interaction controller (both described below) to be used during the presentation of the next scene;

一个动画控制器(符合UIViewControllerAnimatedTransitioning),它从右边缘指示场景的动画;

an animation controller (conforming to UIViewControllerAnimatedTransitioning) that dictates the animation of the scene from the right edge;

一个交互控制器(一个UIPercentDrivenInteractiveTransition),您可以用来通过手势有选择地驱动转换;

an interaction controller (a UIPercentDrivenInteractiveTransition) that you can use to optionally drive the transition via a gesture;

一个表示控制器(一个UIPresentationController子类),该控制器指示是否要删除显示的视图(在这种情况下,您不希望将其删除),以及将与其他chrome一起进行动画处理的镶边新场景的动画演示(例如,您经常使演示视图变暗或模糊);和

a presentation controller (a UIPresentationController subclass) that dictates whether the presented view will be removed or not (in this case you do not want it removed), as well as any other chrome to be animated alongside the animated presentation of the new scene (e.g. you often dim or blur the presenting view); and

手势识别器来驱动交互控制器.

gesture recognizers to drive the interaction controller.

有关更多信息,请参阅WWDC视频使用视图控制器进行自定义转换外观呈现控制器.

For more information, see WWDC videos Custom Transitions Using View Controllers and A Look Inside Presentation Controllers.

请参见 https://github.com/robertmryan/SwiftCustomTransitions/tree/rightside以呈现以下UX的Swift 3示例为例:

See https://github.com/robertmryan/SwiftCustomTransitions/tree/rightside for a Swift 3 example that renders the following UX:

所有这些都相当复杂,您可能需要考虑使用第三方库来显示幻灯片式菜单.但是,如果您想自己动手",则涉及到这些基本内容.

This is all admittedly complicated enough that you may well want to consider third party libraries for presenting slide-in menus. But if you wanted to "roll your own", these are the basic pieces involved.

这篇关于如何在另一个视图控制器的顶部滑动一个视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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