In my app, I want to construct a single background view under my NavigationStack and then show that same background underneath other views that I navigate to via NavigationLinks. I am trying to do this by putting the NavigationStack and my background in a ZStack, but after inspecting the view hierarchy of the app I can see that the NavigationStack is showing its own background in the hosting view controller, and I can't for the life of me figure out how to make it transparent.
Here is a simplified version of my view:
struct Drawer: View {
@State private var selection: DrawerMenuItem? = DrawerMenuItems().options.first
var body: some View {
ZStack {
Color.blue.ignoresSafeArea()
NavigationStack(path: $path) {
List(DrawerMenuItems().options, selection: $selection) { item in
NavigationLink(destination: AnyView(item.view)) {
//Trimmed for brevity
}
}
.scrollContentBackground(.hidden)
}
}
}
}
And here is a screenshot of the resulting view hierarchy:
I am currently using Xcode 15 beta with Swift 5, targeting iOS 17.