๐NavigationLink
NavigationView { // navigation view
List { // list
Section { // list section
// navigation link โญ๏ธ
NavigationLink(destination: ContentView()) {
Label("Settings", systemImage: "gear")
}
// multiple trailing closures โญ๏ธ
NavigationLink {
ContentView()
} label: {
Label("Billings", systemImage: "creditcard")
}
NavigationLink {
Text("No Luck Here.")
} label: {
Label("Help", systemImage: "questionmark")
.tint(.orange) // .tint() DOESN'T workโ๏ธ
}
NavigationLink {
Text("You're not going anywhere.")
} label: {
HStack {
Image(systemName: "gear") // not affected by accent color
Text("Big Settings")
.font(.subheadline.weight(.bold))
}
}
}.tint(.red) // tint (accent) color
Section {
// โญ๏ธ hyperlink
Link(destination: URL(string: "https://apple.com")!) {
HStack {
Label("Apple", systemImage: "house")
Spacer()
Image(systemName: "link").tint(.secondary)
}
}
}.tint(.primary)
}
.listStyle(.insetGrouped) // list style
.navigationTitle("Account") // navigation title
}
NavigationLinks donโt work if they arenโt inside a NavigationView
.
Link - hyperlink
View
.accentColor(_:) - deprecated
Design+Code - Navigation Link and URL
Hacking with Swift - Whatโs new in Swift 5.3? (multiple trailing closures)
Sarunw - tintColor in SwiftUI
Last updated