Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable and even remove the option of EnterFullScreen in View menu in macOS in SwiftUI?

I created a HelloWorld macOS SwiftUI project and I am seeing the option of EnterFullScreen in View menu, so how can I remove this option and disable it from bace in SwiftUI?

@main
struct testApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

enter image description here

like image 439
ios coder Avatar asked Oct 21 '25 11:10

ios coder


1 Answers

You can change this using UserDefaults by setting the key "NSFullScreenMenuItemEverywhere" to false as in this answer but if you do it in applicationWillFinishLaunching as in that answer it will be too late to take effect so move it to the init() in your App struct

init() {
     UserDefaults.standard.set(false, forKey: "NSFullScreenMenuItemEverywhere")
}

If you rather use the AppStorage property wrapper for this it could look like this

@AppStorage("NSFullScreenMenuItemEverywhere") var fullScreenEnabled = false

init() {
     fullScreenEnabled = false
}
like image 144
Joakim Danielson Avatar answered Oct 23 '25 05:10

Joakim Danielson