this is how we can provide navigation bar with navigation bar items
NavigationView {
Text("SwiftUI tutorials")
.navigationBarTitle("Master view")
.navigationBarItems(trailing:
HStack {
Button(action: {
print("SF Symbol button pressed...")
}) {
Image(systemName: "calendar.circle")
.imageScale(.large)
}
Button(action: {
print("Edit button pressed...")
}) {
Text("Edit")
}
}
)
}
to provide kind of detailed view, below can be done
struct DetailView: View {
var body: some View {
Text("Detail view")
}
}
struct ContentView: View {
var body: some View {
NavigationView {
NavigationLink(destination: DetailView()) {
Text("Show detail view")
}
.navigationBarTitle("Master view")
}
}
}
Below is how we can provide navigation bar inline
struct DetailView: View {
var body: some View {
Text("Detail view")
.navigationBarTitle("Detail view", displayMode: .inline)
}
}
references:
https://www.simpleswiftguide.com/swiftui-navigationview-tutorial-with-examples/
No comments:
Post a Comment