window.collectionBehavior = .fullScreenNone
可以禁止全屏 查看文档
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
if let window = NSApplication.shared.windows.first {
window.collectionBehavior = .fullScreenNone // 禁止全屏
}
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}
}
struct ContentView: View {
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some View {
Text("Hello")
.frame(width: 500, height: 500, alignment: .center)
}
}