Question

I would like to create a custom NSTableHeaderView which works well on a black HUD window. I created a subclass of NSTableHeaderView which created this result:

enter image description here

I do no drawing at all. This is the relevant code:

- (void)drawRect:(NSRect)dirtyRect
{
    [NSGraphicsContext saveGraphicsState];
    // no background drawing, just draw the text.
    [NSGraphicsContext restoreGraphicsState];
}

- (BOOL)isOpaque
{
    return NO;
}

How can I get a transparent background?

Was it helpful?

Solution

You need to subclass NSTableHeaderCell instead. This code results in transparent header in my test:

- (void)drawWithFrame:(CGRect)cellFrame inView:(NSView *)view
{
    [self drawInteriorWithFrame:cellFrame inView:view];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top