最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

uikit - How to add custom back button with swipe to back gestures in SwiftUI - Stack Overflow

programmeradmin4浏览0评论

I want to add custom back button to my app with out losing swipe to back gestures.

Adding this

.navigationBarBackButtonHidden(true)

will remove swipe to back gestures

I tried adding below snippet to the code, it was working but i was able to swipe back on my root view also.

`

extension UINavigationController: UIGestureRecognizerDelegate {

    override open func viewDidLoad() {
        super.viewDidLoad()
        interactivePopGestureRecognizer?.delegate = self
    }

    public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        return viewControllers.count > 1
    }
}

`

I have spent lot of time in finding solution for this.

Please help if you have a solution.

发布评论

评论列表(0)

  1. 暂无评论