DismissGestureRecognizer which supports to add a GestureRecognizer for Dismissing UIViewController, the gesture takes effect when a single view controller which isn't in navigationViewController or as a firstViewController in navigationViewController. Compatible with both Swift and Objective-C.
pod 'DismissGestureRecognizer'
github "janlionly/DismissGestureRecognizer"
- iOS: Open Xcode, File->Swift Packages, search input https://github.com/janlionly/DismissGestureRecognizer.git, and then select Version Up to Next Major 1.0.1 < .
- Or add dependencies in your
Package.swift
:
.package(url: "https://github.com/janlionly/DismissGestureRecognizer.git", .upToNextMajor(from: "1.0.1")),
Just one line code to enable the gesture for dismissing view controller:
override func viewDidLoad() {
super.viewDidLoad()
// types: .swipeRightForLeftEdgeScreen, .panRightForLeftEdgeScreen, .disableGesture
dismissType = .swipeRightForLeftEdgeScreen
}
Attention: if set the viewController's modalPresentationStyle is .fullScreen or .currentContext, when dismissing viewController with the gesture, you cann't see the source viewController, replace it with a black background, so if you want to see the source viewController, please set modalPresentationStyle to other styles.
- iOS 8.0+
- Swift 4.2 to 5.2
Visit my github: janlionly
Contact with me by email: janlionly@gmail.com
I would love you to contribute to DismissGestureRecognizer
DismissGestureRecognizer is available under the MIT license. See the LICENSE file for more info.