IOS 幻灯片 In/Out 网络视图

IOS Slide In/Out webview

我对 IOS 应用程序开发还很陌生。

我想实现slide In/out webview(例如从右边),每个人都应该看到一个。

当用户点击 link 时,一个新的 webview 将从右侧滑入并加载网页。如果用户向右滑动,webview 将移回右侧取决于距离的多少。

举几个应用程序具有此功能... Flipboard / Line / Facebook Groups...

注意webview可以被用户水平拖动

在我动手开始这个项目之前,我已经搜索了一段时间。但是,我根本找不到任何东西。

谁能给我指出正确的方向/关键词。如何在 xcode 中设置这样的结构,或者如果存在可以解决问题的现有控件(或默认内置插件)...

谢谢

这种效果很容易通过 swifts 内置的 segue 方法实现。我相信它现在被称为 show,过去被称为 push,但是假设您有 2 个视图,第一个包含 link 或其他内容,第二个是您的 Web 视图。您可以控制故事板中从第一个视图到另一个视图的拖动,并创建一个显示(推送)segue。如果你去寻找这个,有一些代码片段,所以我不想重复它们,但默认动画从右边滑入新视图,当你向右滑动时,视图被推出查看方式老观点。

希望这对你有用,Dom

这不是 segue 或 presentViewController 方法中显示动作的默认 present/dismiss 动画,它看起来是交互式的。要实现这一点,您应该自定义您自己的动画器 class。

如果您使用 presentViewController/dismissViewController 而没有 UINavigationController,请查看 UIViewControllertransitioningDelegate

如果您使用 UINavigationController,请查看 UINavigationController 的委托方法:

func navigationController(_ navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
func navigationController(_ navigationController: UINavigationController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?

恐怕这在IOS动画设计中并不容易。如果您是该领域的新手,您可以使用已经在 Github.

上设计的动画师 classes