How to migrate to swoft ui navigation?
Asked on 08/03/2024
1 search
To migrate to SwiftUI navigation, you can follow these steps based on the content presented at WWDC:
-
Adopt SwiftUI Navigation APIs: If you are currently using a tab bar, you can easily switch to a sidebar by setting the
tabViewStyle
tosidebarAdaptable
. This will transform your tab bar into a sidebar with all its associated behaviors. This is particularly useful for tvOS and iPadOS, where users can switch between tab bar and sidebar representations.TabView { // Your tab views here } .tabViewStyle(SidebarAdaptableTabViewStyle())
-
Use NavigationSplitView: For more complex navigation structures, consider using
NavigationSplitView
. This API allows you to create a split view with a sidebar and a detail view, which is ideal for apps with hierarchical navigation.NavigationSplitView { // Sidebar content } detail: { // Detail content }
-
Integrate SwiftUI with UIKit: If your app is a mix of UIKit and SwiftUI, you can now animate UIKit views using SwiftUI animations. This makes it easier to create fluid, gesture-driven animations and maintain a consistent look and feel across your app.
UIView.animate(withDuration: 0.3) { // UIKit view animations } .animation(.spring())
-
Explore New Transitions: iOS 18 introduces new transitions like the zoom transition, which can be used for both navigation and presentations. This transition is continuously interactive, allowing for a more dynamic user experience.
.transition(.zoom)
For more detailed guidance, you can refer to the following sessions from WWDC 2024:
- Migrate your TVML app to SwiftUI (14:22)
- What’s new in SwiftUI (01:02)
- What’s new in UIKit (02:08)
These sessions provide comprehensive insights into the new features and best practices for adopting SwiftUI navigation in your apps.

Migrate your TVML app to SwiftUI
SwiftUI helps you build great apps on all Apple platforms and is the preferred toolkit for bringing your content into the living room with tvOS 18. Learn how to use SwiftUI to create familiar layouts and controls from TVMLKit, and get tips and best practices.

Platforms State of the Union
Discover the newest advancements on Apple platforms.

Enhance your UI animations and transitions
Explore how to adopt the zoom transition in navigation and presentations to increase the sense of continuity in your app, and learn how to animate UIKit views with SwiftUI animations to make it easier to build animations that feel continuous.