我是 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
如有任何帮助,我们将不胜感激。
最佳答案
您需要将窗口的 collectionBehavior
设置为包含 .fullScreenPrimary
的选项集。
关于swift - 全屏按钮已禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50858585/