Skip to content

Instantly share code, notes, and snippets.

@RuiNelson
Created July 11, 2025 16:19
Show Gist options
  • Select an option

  • Save RuiNelson/5427212070cb511e85f4428ccdd8b547 to your computer and use it in GitHub Desktop.

Select an option

Save RuiNelson/5427212070cb511e85f4428ccdd8b547 to your computer and use it in GitHub Desktop.
How to add overscroll to a Form or a ScrollView in SwiftUI. Here’s the right modifier to achieve the desired effect.
Form {
Text("Form content")
}
.contentMargins(.bottom, 1234.56)
@RuiNelson
Copy link
Author

With the introduction of Liquid Glass and more UI effects in apps, many SwiftUI developers will be looking for an easy way to add overscroll to a Form.

The example above shows what I think is the simplest, cleanest and most reliable approach.

To adjust the overscroll size, just replace 1234.56 with your desired CGFloat value (maybe from your GeometryReader).

This modifier also works great on a ScrollView — and you should definitely use it there too.

Documentation: https://developer.apple.com/documentation/swiftui/view/contentmargins(_:for:)
WWDC session: https://developer.apple.com/videos/play/wwdc2023/10159/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment