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?

Était-ce utile?

La 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];
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top