Skip to content

Instantly share code, notes, and snippets.

@foxicode
Last active August 21, 2023 00:32
Show Gist options
  • Save foxicode/efc6c91bec0dfc8b305733c2b19b25df to your computer and use it in GitHub Desktop.
Save foxicode/efc6c91bec0dfc8b305733c2b19b25df to your computer and use it in GitHub Desktop.
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