Search code examples
swiftmacoscocoa

How to code a view as NSMenuItem in cocoa?


I can work with NSMenu or NSMenuItem but I see apple use color tag in Finder which has animation also, I wander how we could code some thing like this? because all NSMenuItem offer is a string and just one clickable object in a row as a NSMenuItem, but if you look to this image it gave multi clickable object in single row and it has color and animation, almost defining a NSView not just a NSMenuItem, So how we can code something like that as a NSMenuItem?

A screenshot of Mac manu bar with Finder as the selected application, showing the custom tag icons that appear on in the 'File' menu.

Solution

  • NSMenuItem has a view property that you can set.

    See views in menu items.