Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable the Show Tab Bar menu option in SwiftUI

I have created a very simple app on MacOS created with SwiftUI. Default there is a menu item show tab bar. How do I remove this? I doesn't make sense to have tabs in this app.

I've found the following answering the same question, but for older versions of Swift, not for SwiftUI: How do I disable the Show Tab Bar menu option in Sierra apps?

like image 339
ngstschr Avatar asked Nov 30 '25 09:11

ngstschr


1 Answers

Thanks to @JuJoDi

In case you are using SwiftUI life cycle (Scene), you could do the following:

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .onAppear {
                    NSWindow.allowsAutomaticWindowTabbing = false
                }
        }
    }
}
like image 128
user1046037 Avatar answered Dec 03 '25 02:12

user1046037



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!