I'm trying to write a custom NSView that supports adding a background colour. I override drawRect
- (void)drawRect:(NSRect)rect {
[[NSColor blackColor] set];
//[NSBezierPath fillRect:rect]; //I tried this too
NSRectFill([self bounds]);
}
And I set my custom view type to replace the content view NSView of my main window. But when I run it, the background does not turn black as expected - but some contained subviews do.
What I am doing wrong? My draw method is definitely getting called, but background does not change.