Consider a NavigationView
containing a List
of items. How does one give this a background color?
- Putting the
NavigationView
in aZStack
- doesn't work - Putting the
ZStack
in theNavigationView
(code sample below) - doesn't work
struct test: View {
var body: some View {
NavigationView {
ZStack {
Color.blue
List {
ForEach(["1", "2", "3"], id: \.self) { item in
NavigationLink(destination: EmptyView()) {
Text("Some title")
}
}
}
.navigationTitle("Items")
}
}
}
}