Menus and Popovers in Menu Bar Apps for macOS

You probably dont need to create a custom view or mess with the frame. Have a poke around with the imagePosition: NSControl.ImagePosition property and maybe the buttonType also.

Also remember that the tutorial sets the item length as .square . Maybe see how using .variableLength affects things.

Thanks for your quick reply and your suggestions.

Unfortunately, imagePosition only affects the alignment of the image with respect to the text. Without an image, the text is supposed to be centered (of course I tried all the possibilities). Also changing the button type did not solve the issue, although the text position seems to be OK when using NSRadioButton (but that’s not what I need).

The items in the menu bar (and the clock as well) are well aligned, but I can’t find what class that is (NSMenuItem?). Would it be possible to use one of those somehow in the statusItem?

Not sure whats going on for you. I changed the sample project like this…

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

and this

//button.image = NSImage(named: NSImage.Name(rawValue: "StatusBarButtonImage"))
button.title = "Quote!"

And got a string in the status bar. 34

Keep poking at it im sure you’ll work it out.

Hmm, interesting!

I am unable to use .squareLength and .variableLength since I am on 10.11.6 and Xcode 8.2.1. I also had to use .system() instead of .system as you also explained in an earlier comment.

Anyway, thanks for the kind support! I will keep fiddling around with things while I’m learning. :wink:

Best,
Mark

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you! :]