Slide 17
Slide 17 text
NavigationView
Navigation APIの進化
iOS 13.0–17.0 Deprecated
iPadOS 13.0–17.0 Deprecated
iOS 16.0+
iPadOS 16.0+
@State private var isShowingPurple = false
@State private var isShowingPink = false
@State private var isShowingOrange = false
var body: some View {
NavigationView {
List {
NavigationLink("Purple", isActive: $isShowingPurple) {
ColorDetail(color: .purple)
}
NavigationLink("Pink", isActive: $isShowingPink) {
ColorDetail(color: .pink)
}
NavigationLink("Orange", isActive: $isShowingOrange) {
ColorDetail(color: .orange)
}
}
}
.navigationViewStyle(.stack)
}
// Nothing on the stack by default.
@State private var path: [Color] = []
var body: some View {
NavigationStack(path: $path) {
List {
NavigationLink("Purple", value: .purple)
NavigationLink("Pink", value: .pink)
NavigationLink("Orange", value: .orange)
}
.navigationDestination(for: Color.self) { color in
ColorDetail(color: color)
}
}
}
https://developer.apple.com/documentation/swiftui/migrating-to-new-navigation-types
NavigationStack