.edgesIgnoringSafeArea doesn't work properly

299 views Asked by At

I have a NavigationLink inside my ContentView that shows a SecondView with some text. When I apply an .edgesIgnoringSafeArea modifier inside SecondView, the text goes beyond the screen and this only happens inside a NavigationLink when a NavigationBar is hidden.

Can you test this code too if happens to you too?

struct ContentView: View {
@State var hiddenBar = false

var body: some View {
    NavigationView {
        NavigationLink(destination: SecondView(hiddenBar: $hiddenBar)) {
            Text("Go to second View")
        }
        .onAppear {
            self.hiddenBar = false
        }

    .navigationBarTitle("Title", displayMode: .inline)
    .navigationBarHidden(hiddenBar)
    }
}
}

struct SecondView: View {
@Binding var hiddenBar: Bool

var body: some View {
    VStack {
        Text("Text that goes outside of the safe area plus the amount of Navigation Bar height because it's hidden...You can see just this peace of text here")
        Spacer()
    }
    .onAppear {
        self.hiddenBar = true
    }

    .edgesIgnoringSafeArea(.top)
}
}
0

There are 0 answers