zw

NSColor clearColor makes view black

I just came across a problem while programmatically trying to add a label (NSTextField) to a custom view. I wanted the label to have a clear background so the superview would show through, so I added:

[label setBackgroundColor:[NSColor clearColor]];

For some reason, this made the entire background of the label black. Instead I found you can use the following to achieve the desired effect:

[label setDrawsBackground:NO];