SwipePopViewController
Allows swipe back gesture to be started from anywhere on the screen (not only from the left edge)
Requirements
- iOS 9+
- Swift 5
Installation
pod 'SwipePopViewController'
github "ltman/SwipePopViewController"
dependencies: [
.package(url: "https://github.com/ltman/SwipePopViewController")
]
Usage
For the UIViewController
that you want to enable swipe back, just import the library and call addSwipePopGesture()
in viewDidLoad
.
import SwipePopViewController
class YourViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
addSwipePopGesture()
}
}
Background
If you are using UINavigationController
, you will be able to swipe back to pop the top view controller off the navigation stack by default.
However, there are 3 pain points we found with this default swipe back feature:
- iPhone screen is so big that my thumb can't reach the left edge of screen easily.
- Code will get complicated when you want to disable this swipe back on some specific
UIViewController
. - Some app might experience a frame skipping at the beginning of swiping back.
This frame skipping is occurred when
UIViewController
has too many task to do duringviewWillAppear
,viewWillDisappear
.
License
SwipePopViewController is available under the MIT license. See the LICENSE file for more info.