Created
July 11, 2025 16:19
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Form { | |
| Text("Form content") | |
| } | |
| .contentMargins(.bottom, 1234.56) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.56with your desiredCGFloatvalue (maybe from yourGeometryReader).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/