我将NSView设置为全屏模式,并且隐藏菜单栏没有问题。我的问题是退出全屏模式时。如何还原菜单栏?我尝试使用和不使用选项,但结果保持不变:菜单栏丢失:
func exitFullScreen() {
let presOptions: NSApplication.PresentationOptions = [.hideDock, .hideMenuBar]
let optionsDictionary = [NSView.FullScreenModeOptionKey.fullScreenModeApplicationPresentationOptions: NSNumber(value: presOptions.rawValue), NSView.FullScreenModeOptionKey.fullScreenModeAllScreens: false]
presentationWindowController.window?.contentView?.exitFullScreenMode(options: optionsDictionary)
}
实际上,我只需要再次设置应用演示选项:
NSApplication.shared.presentationOptions = []