0

I am trying to build a simple menubar popover app (and have done so) but I cannot get any icon to properly display in menubar. I have attached a photo for what is happening but essentially, a white square appears that is clickable/functioning but is not the icon i want to see. I have tried various setting combinations as well as black (w/ no background), white (w/ no background), and black (w/ white background) in terms of the images I have tried displaying without success. Also, all have been png files.

Can anyone help me figure out what type of image or settings combination I need to be able to display an icon?

According to the tutorial I used, I put a png file in, set the "devices" setting to "universal", set the "render as" option to "template image", and placed the icon in the 2x box. I have played around with different rendering options, as well as different scales (1x, 3x). In case it helps, here is the tutorial I am using: https://www.raywenderlich.com/450-menus-and-popovers-in-menu-bar-apps-for-macos.

this is the line of code in my app delegate that sets the icon to the image:

func applicationDidFinishLaunching(_ aNotification: Notification) {
            if let button = statusItem.button {
                button.image = NSImage(named:NSImage.Name("icon-1"))
                button.action = #selector(togglePopover(_:))
            }
...
}

This is my first stack overflow question so apologies in advance if there is anything that is unclear or if there is information that would be helpful that I didn't provide.

  • Does it work with the icon provided in the article? If yes there's something wrong with your icon. If not there's something wrong with your general setup. – vadian May 04 '19 at 18:17
  • Oh yeah that worked. Don't really understand why, though. The image from the tutorial is 446 bytes compared to closer to 5 or more kb that my other images were so I'd guess that was the issue but not sure. Thanks for the help! – Nikhil Deo May 05 '19 at 13:56
  • It's not a question of image size. If you want to use a icon as template icon it must be a bitmap image (black and white, no grayscale, no colors). – vadian May 05 '19 at 14:52

0 Answers0