Frage

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?

War es hilfreich?

Lösung

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];
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top