As I am new to OS X development I don't have good knowledge of OS X components. In my app I need to cover whole screen with view but I am only able to do this when my Menu bar is hidden. As other app I want to cover whole screen with Menu Bar. Now I am presenting View as popover but my requirement is not pop view but cover all view as blur view in IOS. My project is in Swift 2.1
What I have done
let presOptions: NSApplicationPresentationOptions =
([
.HideDock,
.HideMenuBar ,
.DisableAppleMenu,
.DisableForceQuit,
.DisableProcessSwitching,
.DisableSessionTermination,
.DisableHideApplication,
.AutoHideToolbar
])
let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions :
NSNumber(unsignedLong: presOptions.rawValue)]
self.view.enterFullScreenMode(NSScreen.mainScreen()!, withOptions:optionsDictionary)
self.view.wantsLayer = true
}
My requirement
My Output
Solution to me on Swift 2.0
let newWindow = NSWindow(contentRect: NSMakeRect(0, 0, NSScreen.mainScreen()!.frame.width, NSScreen.mainScreen()!.frame.height), styleMask: NSBorderlessWindowMask, backing: NSBackingStoreType.Buffered, `defer`: false)
func applicationDidFinishLaunching(aNotification: NSNotification) {
newWindow.title = "New Window"
newWindow.opaque = false
newWindow.backgroundColor = NSColor(calibratedHue: 0, saturation: 1.0, brightness: 0, alpha: 0.5)
newWindow.makeKeyAndOrderFront(nil)
newWindow.level = Int(CGWindowLevelForKey(CGWindowLevelKey.ScreenSaverWindowLevelKey))
}
您应该使用级别NSScreenSaverWindowLevel - 1创建NSWindow,根据此链接,它可以工作: http : //www.cocoabuilder.com/archive/cocoa/33048-floating-window-over-menu-bar.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.