Я пытаюсь удалить все команды в macOS с помощью .commandsRemoved(), который хорошо справляется со своей задачей, но я вижу, что есть некоторые, которые не были удалены, например ShowTabBar или ShowAllTabs:
@main
struct testApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.commandsRemoved()
}
}





Вы не можете удалить меню заголовка приложения на панели, но следующее поможет удалить все команды под ним. Сначала добавьте следующую строку кода в свое приложение struct:
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
Затем создайте новый файл с именем AppDelegate (или как вы помните — это также может быть в том же файле). Создайте AppDelegate:
//In the file, you must import `AppKit`
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationWillFinishLaunching(_ notification: Notification) {
NSWindow.allowsAutomaticWindowTabbing = false //<-- This is the key!
//This will hide all of the fullscreen and tab menu controls
}
}
Этот код был протестирован с Xcode 14 и macOS 13.
https://stackoverflow.com/a/65634944/20384561
https://developer.apple.com/documentation/appkit/nswindow/1646657-allowsautomaticwindowtabbing