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
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()
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.