0

enter image description here

Code I used to create an example of this navigation bar:

struct ContentView: View {
    init() {
        let defaultAppearance = UINavigationBarAppearance()
        defaultAppearance.configureWithOpaqueBackground()
        defaultAppearance.backgroundColor = .red

        UINavigationBar.appearance().standardAppearance = defaultAppearance
        UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
    }

    var body: some View {
        ParentView()
    }
}

struct ParentView: View {
    var body: some View {
        NavigationView {
            VStack {
                NavigationLink(destination: DetailView()) {
                    Text("Tap here")
                }
            }
            .navigationBarTitle("", displayMode: .inline)
            .navigationBarHidden(true)
            .edgesIgnoringSafeArea(.all)
        }
    }
}

struct DetailView: View {
    var body: some View {
        VStack {
            Text("Detail View")
        }
        .edgesIgnoringSafeArea(.all)
   }
}

It doesn't matter where I'm putting .edgesIgnoringSafeArea(.all) it doesn't work. Is there another way to tell Navigation Bar to ignore the safe area?

If it's not the safe area problem, then I need to make the whole navigation bar to have the same height of UINavigationBarContentView displayed in UI Hierarchy: enter image description here

netsplatter
  • 559
  • 3
  • 14

0 Answers0