0

I'm trying to create an status bar item with text and image. I would like to have the image on the left side and the text (title) next to it. But the title is painted on top of the image.

It worked as expected by directly setting the image and title on the statusItem what is deprecated now.

Can someone help me with the correct code?

let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)

    func showNormalIcon(title: String, tooltip: String) {
        if error {
            error = false
            let icon = NSImage(named: "statusIcon")
            statusItem.button?.image = icon?.tinted(color: .white)
        }
        statusItem.button?.title = title
        statusItem.button?.toolTip = tooltip
    }
Sven
  • 1

0 Answers0