objective-cmacoscocoansmenumacos-darkmode

How to get dynamic NSMenu to use Mojave Dark Mode?


My OS is set to dark mode, and my whole app renders properly, except for some dynamically created NSMenu instances, which render in the old light style.

How do I get those menus to render using a dark visual style?


Solution

  • The dark visual style is only applied if you specify the parent view.

    If view is nil here, the old style will be used instead:

    NSMenu* menu;
    NSView* view; // cannot be nil
    [menu popUpMenuPositioningItem:nil atLocation:NSMakePoint(0, 0) inView:view];