Search code examples
hidestatusbarswiftui

How to hide the status bar in SwiftUI


I want to hide the status bar in SwiftUI. I have try the method "statusBar(hidden: true)", but it doesn't work. Is there any solution to make it in SwiftUI.

the demo code as below:

var body: some View {
        VStack {
            Text("Hello World")

        }
        .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
        .background(Color.blue)
        .edgesIgnoringSafeArea(.all)
        .statusBar(hidden: true)

    }

Solution

  • .edgesIgnoringSafeArea(.all)
    .statusBar(hidden: true)
    

    try this