I am coming from iOS/Android programming background and working on my first MAC application. I am using an NSComboBox
to list some item that user can choose but having some trouble setting the background color of the drop down menu.
What I have currently?
This is what I have now. You can see the 2 options in drop down coming in a white background (forget the blue, it shows the item is selected). I want to change the white to some other color
What I have done?
I did some searching and come across this thread. The answer suggests subclassing NSComboBoxCell and overriding - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
method. I tried it out.. This is my code
@interface CustomComboBoxCell : NSComboBoxCell
@end
@implementation CustomComboBoxCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView{
[super drawWithFrame:cellFrame inView:controlView];
//I want red color to the dropdown menu, I filled with yellow color
NSRect bounds = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y,
cellFrame.size.width, cellFrame.size.height);
[[NSColor redColor] setFill];
NSRectFill(bounds);
}
@end
and this is the result
Not what I wanted. :(
Question
Simple, how can I change the background color of drop down menu of NSComboBox
?
Anyone?