SwiftUI ScrollView supporting pull-to-refresh

What's New



In iOS 16.0, a scroll view automatically gets a scroll indicator if it is refreshable, so we don't need to add our shenanigans.

In this situation we just wrap the contents in an unadorned ScrollView.


Provides a SwiftUI implementation of ScrollView which supports the .refreshable modifier.

Currently, the only way to get pull-to-refresh behaviour in SwiftUI is to use a List. This may not always be what you want, as List has some performance issues.

The views in this package are intended for situations where you want pull-to-refresh, but don't want to use List.

This package provides two implementations:

  1. A pure SwiftUI one: RefreshableScrollView. This works when embedded in a navigation view, and has hint flags that you can pass to help adjust the layout of the refresh control. The downside is that the precise pull-to-refresh behaviour is very slightly different from the UIKit implementation. This is because we cannot use a UIRefreshControl, as that only works when attached to a UIScrollView, which we don't have.

  2. An implementation which uses UIKit: NativeRefreshableScrollView. This uses a real UIScrollView, which contains a UIHostingController, which contains the SwiftUI content views. Doing this means that we can use UIRefreshControl for the activity/refresh indicator, and get the precise pull-to-refresh behaviour and appearance from UIKit. The downside is that it does not seem to play well if embedded inside a NavigationView; the positioning of the refresh control seems to change as soon as the refresh task begins, causing it to disappear, which looks rubbish.


See Extras/Example for an example Xcode project which uses this package.


My FastList package is a client of this package. FastList is intended as a replacement for SwiftUI's native List, in situations where you have a large number of items and SwiftUI performance struggles (because of the fancy animations that it tries to do).


This code builds on or takes inspiration from a few examples out there, including:

Thanks to these and others for showing the way.


  • Swift Tools 5.5.0
View More Packages from this Author


Last updated: Fri Nov 11 2022 09:16:06 GMT-0500 (GMT-05:00)