I have created a status item (menu bar item) for my app, but at the moment it’s title is text, how would I make it show an image?
This is the part of the code which sets the title. What would I need to change to that code to make it display an image?
[item setTitle:@"MenuItem"];
You use the setImage: method, supplying it with an
NSImagewhich you want to display on the menu bar.Note also that you can have an
NSStatusItemshowing an image and text, for example with the battery indicator.Here is a small example setting the image to a file named
OtherImage.jpg:Make sure that the file OtherImage.png is actually added to your Xcode project and copied into the application’s
Resourcesdirectory. If your image does not load, it means that the file is not named correctly, not really an image, or not actually in the application bundle.