我是Cocoa Apps开发的新手。由于某些未知原因,我的fullscreen
按钮被禁用。可能问题出在styleMask
。这是我的代码:
class AppDelegate: NSObject, NSApplicationDelegate {
lazy var window = NSWindow(contentRect:
NSRect(center: NSScreen.main?.frame.center ?? .zero, size: CGSize(width: 800, height: 450)),
styleMask: [.titled, .miniaturizable, .closable, .fullSizeContentView],
backing: NSWindow.BackingStoreType.buffered,
defer: false)
func applicationDidFinishLaunching(_ aNotification: Notification) {
let vc = Router.getPhotoBrowserNSViewController()
window.contentViewController = vc
window.delegate = NSWindowHandler()
window.titlebarAppearsTransparent = true
window.isMovableByWindowBackground = true
window.makeKeyAndOrderFront(nil)
window.maxFullScreenContentSize = NSScreen.main?.frame.size ?? .zero
window.minFullScreenContentSize = CGSize(width: 800, height: 450)
}
}
结果如下: https://imgur.com/NE4fgfG
任何帮助都将不胜感激。
答案 0 :(得分:2)
您需要将窗口collectionBehavior
设置为包含.fullScreenPrimary
的选项集。