Search code examples
objective-cmacoscocoanstableviewnsoutlineview

How to draw half-transparent NSTableRowView?


I want to customize drawing of floating group row background and can't do it. Basically I want a partially transparent background (which always keeps the same look when scrolling or not), but something alters the appearance of my subclass of NSTableRowView when the table view is not scrolling (though when scrolling it looks as intended). Here's the code and the image explaining the issue.

- (void)drawBackgroundInRect:(NSRect)dirtyRect
{
    [[NSColor colorWithCalibratedWhite:1.0 alpha:0.5] set];
    [[NSBezierPath bezierPathWithRect:dirtyRect] fill];
}

For table cell view I tried to use NSTableCellView, NSView and simple NSTextField (this is the one you see on the image), but the result is always the same.

enter image description here


Solution

  • I was able to fix it by turning on Core Animation layer on the header cell view and its table view.