1

How the scroll view looks normally

What I DON'T WANT TO HAPPEN

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!

  • For usability and user experience on iOS I would leave it like it this because this is the natural behavior of the scrollview – adri567 Oct 17 '22 at 20:20
  • Does this answer your question? [How to disable ScrollView Bounce In SwiftUI](https://stackoverflow.com/questions/58799474/how-to-disable-scrollview-bounce-in-swiftui) – Ptit Xav Oct 18 '22 at 12:19

1 Answers1

1

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

hallo
  • 825
  • 1
  • 7
  • 10