I need to make NSMenuItem with icon at the right side. I ended up with custom view which contains NSTextField and NSImageView on top of NSVisualEffectView with selection material, that I use to imitate system selection. NSVisualEffectView is hidden by default. But when the item is selected, my NSVisualEffectView appears on screen and image is drawn with background. How can I get rid of it? wantsLayer = YES and backgroundColor = CGColor.clear did not help. Thanks in advance.
You don't need to add NSVisualEffectView explicitly. By default, menu items have NSVisualEffectView as superView. You can use that VisualEffectView to imitate the selection behavior. Click here to download a demo project.
Set image's isTemplate
property to true. It will change according to appearance of menu item.