swiftNoob6000
swiftNoob6000

Reputation: 41

Changing background color of NavigationView in SwiftUI

Is there a way to change the color of a NavigationView or to make it clear so the elements underneath are visible?

struct SwiftUIView: View {
    var body: some View {
        
        ZStack {
            Color.red.edgesIgnoringSafeArea(.all) //not visible beacause of NavigationView
            
            NavigationView {
                Text("Hello, World!")
            }.background(Color.clear) //this does nothing
        }
        
    }
}

Upvotes: 2

Views: 1057

Answers (1)

Lukas
Lukas

Reputation: 291

I would do this:

struct SwiftUIView: View {
var body: some View {
   NavigationView {
        ZStack{
            Color.red.edgesIgnoringSafeArea(.all)
            Text("Hello, World!")
        }
   }
}
}

Upvotes: 2

Related Questions