๐NavigationView
Adding a Text
view is a useful way to give the second column (details pane, or primary pane) a placeholder view.
๐ see example 1 below.
// example 1
NavigationView {
// โญ๏ธ `List` of `NavigationLink`s
List(model.notes) { note in
NavigationLink(note.title, destination: NoteEditor(id: note.id))
}
// โญ๏ธ ้้จๅ็ซ็ถๆใ่ชๅๅบ็พใ่ไธใๅชๅบ็พใๅจ "details pane"โ๏ธ
Text("Select a Note")
}
// example 2
struct AccountView: View {
var body: some View {
NavigationView { // navigation view
List { // list
Section { // list section
Text("Settings")
Text("Billings")
Text("Help")
}.listRowSeparatorTint(.gray) // color of the separator
Section { // list section
Text("Feedback")
Text("Support")
}.listRowSeparator(.hidden) // hide separators
}
.listStyle(.insetGrouped) // list style
.navigationTitle("Account") // navigation title
}
}
}
SwiftUI โฉ
Presentation Containers โฉ NavigationView โฉ
.navigationBarTitle()deprecated.
List is used as content.
use NavigationLink to navigate to other views.
Last updated