mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 09:41:00 +00:00
29 lines
1.1 KiB
Swift
29 lines
1.1 KiB
Swift
// Copyright © 2022 Metabolist. All rights reserved.
|
|
|
|
import UIKit
|
|
|
|
// ref: https://stackoverflow.com/a/60598558/3797903
|
|
class SwipeableNavigationController: UINavigationController {
|
|
private lazy var fullWidthBackGestureRecognizer = UIPanGestureRecognizer()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
setupFullWidthBackGesture()
|
|
}
|
|
|
|
private func setupFullWidthBackGesture() {
|
|
guard let targets = interactivePopGestureRecognizer?.value(forKey: "targets") else { return }
|
|
|
|
// have fullWidthBackGestureRecognizer execute the same handler as interactivePopGestureRecognizer
|
|
fullWidthBackGestureRecognizer.setValue(targets, forKey: "targets")
|
|
fullWidthBackGestureRecognizer.delegate = self
|
|
|
|
view.addGestureRecognizer(fullWidthBackGestureRecognizer)
|
|
}
|
|
}
|
|
|
|
extension SwipeableNavigationController: UIGestureRecognizerDelegate {
|
|
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
|
interactivePopGestureRecognizer?.isEnabled == true && viewControllers.count > 1
|
|
}
|
|
}
|