what's new with navigation in SwiftUI ?

Asked on 08/22/2024

1 search

In the "What's new in SwiftUI" session at WWDC 2024, several enhancements to navigation in SwiftUI were introduced. These include:

  1. Scrolling Enhancements: SwiftUI now offers more programmatic control over scroll views. You can react to changes in content, offsets, and content size with the onScrollGeometryChange modifier. This allows for dynamic interactions, such as showing a button when scrolling past a certain point. Additionally, you can detect when a view's visibility changes due to scrolling, enabling experiences like auto-playing videos when content comes into view. There are also new options for controlling scroll positions, such as scrolling to the top edge, and more control over content alignment and scrolling behavior.

  2. Tab and Sidebar Flexibility: The sidebar in iOS 18 has become more flexible, allowing users to switch between a tab bar and a sidebar representation. The tab bar can now float above the content, and users can customize the experience by reordering items and hiding infrequently used options. This is achieved using the new type-safe syntax for TabView in SwiftUI, which helps catch common errors at build time.

  3. Zoom Navigation Transition: A new Zoom navigation transition has been introduced, which can be used to create visually appealing transitions when expanding information within an app.

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