[英]How can I disable and even remove the option of EnterFullScreen in View menu in macOS in SwiftUI?
[英]How can I remove all commands in macOS?
您無法刪除欄上的應用程序標題菜單,但以下內容可以刪除其下的所有命令。 首先,將以下代碼行添加到您的 App 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.