what are the new scrollview apis on ios 18?

Generated on 7/31/2024

1 search

In iOS 18, there are several new ScrollView APIs introduced in both UIKit and SwiftUI. Here are the key updates:

SwiftUI

  1. Programmatic Control: You have more programmatic control over your ScrollView, including more scroll positions to programmatically scroll to, such as the top edge.
  2. Scroll Geometry Change: The onScrollGeometryChange modifier allows you to react to changes in content offsets, content size, and more.
  3. Visibility Detection: You can detect when a view's visibility changes due to scrolling, enabling experiences centered around content moving on or off screen.
  4. Scroll Target Behavior: The scrollTargetBehavior can be set to viewAligned to help make transitions more definite.
  5. Content Alignment: You can control your content alignment and turn off bouncing along a given axis.
  6. Stopping Scrolling: There are options to programmatically stop scrolling.

For more details, you can refer to the session What’s new in SwiftUI (16:47).

UIKit

While the context does not provide specific new ScrollView APIs for UIKit in iOS 18, it mentions general improvements and new features in UIKit, which may include enhancements to existing components like ScrollView.

TVOS

  1. On Scroll Visibility Change: Similar to SwiftUI, TVOS 18 introduces the onScrollVisibilityChange modifier to react to visibility changes when content moves off screen.
  2. View Modifiers: New view modifiers specific to ScrollView are introduced to enhance the scrolling experience.

For more details, you can refer to the session Migrate your TVML app to SwiftUI (10:07).

Sessions Mentioned

  1. What’s new in UIKit
  2. What’s new in SwiftUI
  3. Migrate your TVML app to SwiftUI

These updates provide developers with more tools and flexibility to create rich, interactive scrolling experiences in their apps.