Reputation: 105
I already searched, but can't find a solution that works.
I have this super simple code. When I add the NavigationView, the background color goes away.
I think if I can make the background color of NavigationView Transparent, it would solve the issue.
struct TestView: View {
var body: some View {
VStack {
Spacer()
NavigationView {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
Spacer()
}
.background(Color(red: 128 / 255, green: 27 / 255, blue: 44 / 255))
.ignoresSafeArea(.all)
}
}
Thanks in advance
Upvotes: 6
Views: 4771
Reputation: 27
I had the exact same issue. I managed to solve this by keeping the 'NavigationView' as the parent and having the ZStack as the child for your background
So to take your code:
var body: some View {
Spacer()
NavigationView {
ZStack {
//Your colour here + Safezone ignore
}
VStack {
Text("Hello, World!")
Spacer()
}
}
}
}
Upvotes: 1