create navbar swiftui code example
Example: navigation bar title ios 13 siwftui
import SwiftUI
struct People: Identifiable{
var id = UUID()
var name = String()
}
struct ContentView: View {
let people: [People] = [
People(name: "Bill"),
People(name: "Jacob"),
People(name: "Olivia")]
var body: some View {
NavigationView {
List(people) { listedPeople in
NavigationLink(destination: DetailView(name: listedPeople.name)) {
VStack(alignment: .leading){
Text(listedPeople.name)
}
}
}
.navigationBarItems(leading:
HStack {
Button(action: {}) {
Image(systemName: "minus.square.fill")
.font(.largeTitle)
}.foregroundColor(.pink)
}, trailing:
HStack {
Button(action: {}) {
Image(systemName: "plus.square.fill")
.font(.largeTitle)
}.foregroundColor(.blue)
})
.navigationBarTitle(Text("Names"))
}
}
}
struct DetailView: View {
var name: String
var body: some View {
Text("current name is: \(name) ")
.navigationBarTitle(Text("Current Name"), displayMode: .inline)
}
}