Some background styles seem to require special compositing (probably due to the shadows?).
OS X uses a cached & scaled representation of the superviews background when drawing the NSTextField
.
I used your drawing code but changed the top color to make the cached drawing more apparent:
I found 2 workarounds:
- Simply enable layer backing on the superview of the label.
- When you can't enable layer backing, you could enforce a re-display of the label's superview. e.g. in the
NSWindowDelegate
methodwindowDidUpdate:
The second approach feels a bit hacky though:
- (void)windowDidUpdate:(NSNotification*)notification
{
[self.label.superview setNeedsDisplay:YES];
}
Result: