Skip to content

Instantly share code, notes, and snippets.

@foxicode
Last active August 21, 2023 00:32
Navigation in SwiftUI
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
VStack {
Text("Original content view")
NavigationLink {
InnerContentView()
} label: {
Text("Tap me to see the second screen")
}
}
.padding()
.navigationTitle("Root view")
}
}
}
struct InnerContentView: View {
var body: some View {
Text("Inner content view")
.navigationTitle("Details view")
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment