What’s new in scrollview

Asked on 2024-07-30

1 search

In the WWDC 2024 session titled What’s new in SwiftUI, several enhancements to ScrollView were introduced:

  1. Programmatic Control: You now have more programmatic control over your scroll views, including more scroll positions to programmatically scroll to, such as the top edge.
  2. Scroll Visibility Change: The new onScrollVisibilityChange modifier allows you to detect when a view's visibility changes due to scrolling. This can be used to create experiences centered around content moving on or off screen, like auto-playing videos.
  3. Scroll Geometry Change: The onScrollGeometryChange modifier lets you react to changes in content offsets, content size, and more, enabling deeper integration with the state of a scroll view.
  4. Content Alignment and Bouncing: Additional options are available to control content alignment, turn off bouncing along a given axis, and programmatically stop scrolling.

For more detailed examples and advanced techniques, you can refer to the session Migrate your TVML app to SwiftUI, which demonstrates the use of these new scroll view modifiers in tvOS 18.

Additionally, the session Create custom visual effects with SwiftUI explores how to use the scrollTransition modifier to create custom scroll effects, such as parallax effects and unique scroll experiences.

Relevant Sessions:

  1. What’s new in SwiftUI
  2. Migrate your TVML app to SwiftUI
  3. Create custom visual effects with SwiftUI