Skip to content

janlionly/DismissGestureRecognizer

Repository files navigation

DismissGestureRecognizer

Version Carthage Compatible License Platform Swift

Description

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.

Installation

CocoaPods

pod 'DismissGestureRecognizer'

Carthage

github "janlionly/DismissGestureRecognizer"

Swift Package Manager

.package(url: "https://github.com/janlionly/DismissGestureRecognizer.git", .upToNextMajor(from: "1.0.1")),

Usage

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.

Requirements

  • iOS 8.0+
  • Swift 4.2 to 5.2

Author

Visit my github: janlionly
Contact with me by email: janlionly@gmail.com

Contribute

I would love you to contribute to DismissGestureRecognizer

License

DismissGestureRecognizer is available under the MIT license. See the LICENSE file for more info.