How the scroll view looks normally
As you can see from the images, I do not want to allow users to be able to scroll further up if they are already at the top, or scroll further down if they are already at the bottom.
What would be the best way to do this?
I would appreciate a detailed response. Thanks!
CodePudding user response:
Well first of all, that is default iOS behavior and disabling it will feel weird.
This is currently not supported directly in SwiftUI, but you can look through the view hierarchy to find the underlying UIScrollView
and then disable the bounce on it.
The easiest way to do this is adding Introspect to your app and then
ScrollView {
...
}
.introspectScrollView { scrollView in
scrollView.bounces = false
}
This will disable the bounce on the scrollview preventing a user from overscrolling