how to track scroll in swiftui

Asked on 03/17/2025

1 search

To track scroll in SwiftUI, you can use the new APIs introduced in the latest updates. Specifically, SwiftUI now provides more granular control over scroll views with the onScrollGeometryChange modifier. This allows you to react to changes in content, offsets, content size, and more. For example, you can detect when a view's visibility changes due to scrolling, enabling you to create experiences centered around content moving on or off the screen.

For more detailed information, you can refer to the session What’s new in SwiftUI (16:18) where scrolling enhancements are discussed.