蘇哲聖
蘇哲聖

Reputation: 795

Hide Navigation bar for `TabView` not working

In swiftUI, iOS14. I can not hide the navigation bar of TabView. Here is my code:

struct ContentView: View {
    var body: some View {
        NavigationView {
            TabView() {
                List {
                    Text("Hi!")
                    Text("How are you?")
                }
            }
            .navigationTitle("")
            .navigationBarHidden(true) // not working!!
        }
    }
}

Is this a bug? How to resolve this problem?Navigation Bar exists!

Upvotes: 4

Views: 687

Answers (1)

YodagamaHeshan
YodagamaHeshan

Reputation: 6500

You need to move .navigationBarHidden(true) inside to TabView.


  struct ContentView: View {
        var body: some View {
            NavigationView {
                TabView() {
                    List {
                        Text("Hi!")
                        Text("How are you?")
                    }
                    .navigationBarHidden(true) //<= here
                }
            }
        }
    }

Upvotes: 3

Related Questions