For each NSMenuItem in your menu, you need to set the corresponding image by calling setImage:
In short, you need to prepare your menu item, attach it to the menu and attach it to your pop-up button, for example:
NSPopUpButton *yourButton = [[NSPopUpButton alloc] init]; NSMenu *yourMenu = [[NSMenu alloc] init]; NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"some label" action:nil keyEquivalent:@""]; NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:@"yourFilePath"]; [iconImage setSize:NSMakeSize(16,16)]; [menuItem setImage:iconImage]; [yourMenu insertItem:menuItem atIndex:0]; [yourButton setMenu:yourMenu];
Pay attention to the use of iconForFile: in NSWorkspace , which allows you to display the same icon as in Finder.
For more examples, you can see this sample Apple code: ButtonMadness
source share