Display an icon and text on NSStatusBar for macOS using Swift

694 Views Asked by At

I would like to display an icon and some texts to its right on a NSStatusBar.

The code I'm using, as seen below, displays the icon and the text overlapping.

This is an example of I'm trying to emulate:

status bar example

And here's my current code for reference:

let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.variableLength)
var preferencesWindow: NSWindowController?

func applicationDidFinishLaunching(_ aNotification: Notification) {
    if let button = statusItem.button {
        button.image = NSImage(named:NSImage.Name("StatusBarButtonImage"))
        button.title = "..."
    }
    initMenu()
}
0

There are 0 best solutions below