Reading time: 1 min

This recipe shows how to disable scrolling in a ScrollView or List, while still allowing interactions with its subviews. The end result looks like this:

preview

The trick is to use a DragGesture with minimumDistance of zero, which will then intercept scrolling touches, while still allowing taps an...

Continue Reading...

Reading time: 1 min

This recipe shows how to add a sticky header to a List in SwiftUI. It also allows for a scrolling part of the header, as well as multiple sticky headers. The end result looks like this:

preview

The recipe goes as follows:

  • Use Section(header:) to define the sticky header and the content beneath...

Continue Reading...

Reading time: 1 min

This recipe shows how to update navigation bar when the content underneath it scrolls. The end result looks like this:

preview

The recipe relies on the ObservableScrollView from this recipe, because it can track its scroll offset. After that, it becomes trivial to check if the user has scrolled p...

Continue Reading...

Reading time: 1 min

This quick recipe shows how to scroll a SwiftUI ScrollView programatically when the scrolling trigger is not wrapped in a ScrollViewReader. E.g, the image below shows scrolling triggered from navigation bar buttons:

preview

As you know, you can scroll a ScrollView programatically using a Scroll...

Continue Reading...

Reading time: 2 min

This recipe shows how to get current scroll offset of a SwiftUI ScrollView. The necessary functionality is wrapped in a new component, ObservableScrollView, which works exactly the same as ScrollView does, but also exposes its current scroll offset in a binding. The end result looks like thi...

Continue Reading...