好的,我有正确的想法,棘手的部分是所有选项如何相互作用。这是有效的:
- NSPanel,不是NSWindow
- 风格面具:
[.borderless, .nonactivatingPanel]
还有这些属性:
panel.level = .mainMenu
panel.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
斯威夫特 4.2 代码
使用这些设置创建并显示面板。然后您可以将面板拖到全屏应用程序上(双显示器设置)。
let panel2 = NSPanel(contentRect: NSRect(x: 0, y: 0, width: 200, height: 200), styleMask: [.titled, .nonactivatingPanel], backing: .buffered, defer: true)
panel2.level = .mainMenu
panel2.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
panel2.orderFrontRegardless()
切换到无边框将阻止用户移动您的窗口。
let panel2 = NSPanel(contentRect: NSRect(x: 0, y: 0, width: 200, height: 200), styleMask: [.borderless, .nonactivatingPanel], backing: .buffered, defer: true)
panel2.level = .mainMenu
panel2.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
panel2.orderFrontRegardless()