I have an NSPopMenuButton which is connected to an NSMenu in the standard way. I tried sub-classing both in an attempt to change the background color of the menu itself. I'm clearly not doing something correctly, so any advice would be helpful.
Tried (NSPopUpButton) customPopUpButton.m:
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// Drawing code here.
[[NSColor grayColor] set];
NSRectFill(dirtyRect);
}
Which gave me:
I'd actually rather it be like:

I tried creating another class to override NSPopUpButtonCell as suggested by another answer, but I must not know how to implement it correctly as it seems to have no effect other than what the code above does.
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
[[NSColor grayColor] set];
NSRectFill(cellFrame);
[super drawInteriorWithFrame:cellFrame inView:controlView];
}
Something to note is that my deployment target is macOS 10.11 if that makes any difference.
Your customized
NSPopUpButtondrawing is filling the entire drawing area with color. Default title drawing is missing (under the filled color).Try customizing
NSPopUpButtonCell drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView.