macosswiftosx-yosemite

"Application is agent" doesn't work in Swift


I'm working on a status bar app in Swift. I tried to hide the window by adding Application is agent (UIElement) item and set it to YES, but it just doesn't work - it always shows the window and the menu bar.

My storyboard:

enter image description here

Info.plist:

enter image description here

What can I do ?


Solution

  • Configure your NSStatusBar with a title, image, alternate image, etc.. and you'll see it in the system's Status Bar.

        let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(NSVariableStatusItemLength)
    
        statusItem.button?.title = "LG"
        statusItem.button?.image = NSImage(named: "LGIcon")
        statusItem.button?.alternateImage = NSImage(named: "LGIcon")