Skip to content

Instantly share code, notes, and snippets.

@TuenTuenna
Last active March 22, 2022 13:48
Show Gist options
  • Save TuenTuenna/906a123b07544e319993d71759920a81 to your computer and use it in GitHub Desktop.
Save TuenTuenna/906a123b07544e319993d71759920a81 to your computer and use it in GitHub Desktop.
SwiftUi 팝 스와이프 제스쳐 처리
// SwiftUi 드래그 팝 제스쳐 가능하도록 등록 
extension UINavigationController: ObservableObject, UIGestureRecognizerDelegate {
    override open func viewDidLoad() {
        super.viewDidLoad()
//        navigationBar.isHidden = true
        interactivePopGestureRecognizer?.delegate = self
    }

    public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        return viewControllers.count > 1
    }
}
// 사용예 위와 같이 익스텐션 등록만 해두면 어디든 적용된다.

출처

https://medium.com/hcleedev/swift-custom-navigationview%EC%97%90%EC%84%9C-swipe-back-%EA%B0%80%EB%8A%A5%ED%95%98%EA%B2%8C-%ED%95%98%EA%B8%B0-c3c519c59bcb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment