Created
May 5, 2023 06:48
-
-
Save imjhk03/c18f3aa4371f7ffafcd065d37b8cec7c to your computer and use it in GitHub Desktop.
Enable swipe back when navigation bar is hidden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SwipeBackGestureViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
navigationController?.hidesBarsOnSwipe = true | |
navigationController?.interactivePopGestureRecognizer?.delegate = self | |
} | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidDisappear(animated) | |
navigationController?.interactivePopGestureRecognizer?.isEnabled = navigationController?.viewControllers.count ?? 0 > 1 | |
} | |
override func viewDidDisappear(_ animated: Bool) { | |
super.viewDidDisappear(animated) | |
navigationController?.interactivePopGestureRecognizer?.delegate = nil | |
} | |
} | |
extension SwipeBackGestureViewController: UIGestureRecognizerDelegate { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment