I have a list in SwiftUI View. Which is in UIHostingController. I want to hide or show UINavigationBar on the basis of the Scroll Direction of the List. This UINavigationBar is in UIkit in UIHostingController. I tried adding DragGesture but it doesn't give continuous updates on the Scroll direction.
override func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.panGestureRecognizer.translation(in: scrollView).y < 0 {
navigationController?.setNavigationBarHidden(true, animated: true)
} else {
navigationController?.setNavigationBarHidden(false, animated: true)
}
}
Basically, I need a replacement of the above code in SwiftUI.
Please don't suggest LazyList or any solution related to iOS 14, as my min iOS target is iOS 13.