SwipePopViewController 0.3.4

SwipePopViewController 0.3.4

Thanapat SorralumpChalermpong SatayavibulChalermpong SatayavibulAthipat NampetchChainarhong 维护。



  • 作者:
  • chalermpong

SwipePopViewController

Test Version License Platform

允许从屏幕上的任何位置开始滑动返回手势(而不仅仅是从左侧边缘)

需求

  • iOS 9+
  • Swift 5

安装

pod 'SwipePopViewController'
github "ltman/SwipePopViewController"
dependencies: [
  .package(url: "https://github.com/ltman/SwipePopViewController")
]

使用

对于您想要启用滑动返回的 UIViewController,只需导入库并在 viewDidLoad 中调用 addSwipePopGesture()

import SwipePopViewController

class YourViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        addSwipePopGesture()
    }
}

背景

如果您正在使用UINavigationController,则默认情况下,您可以通过向左滑动来弹出栈中的最顶层视图控制器。

然而,我们发现了关于这个默认的滑动返回功能三个痛点

  1. iPhone屏幕非常大,以至于我的拇指难以轻松地触碰到屏幕的左侧边缘。
  2. 当您希望在某些特定的UIViewController上禁用此滑动返回时,代码会变得复杂。
  3. 某些应用程序在滑动返回的开始时可能会出现帧跳过。当UIViewControllerviewWillAppearviewWillDisappear中要执行太多的任务时,就会发生这种帧跳过。

许可

SwipePopViewController遵循MIT许可协议。有关更多信息,请参阅LICENSE文件。