Question

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

Was it helpful?

Solution

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

OTHER TIPS

If you're not doing anything other than filling the background of the row with a color, you should be setting the backgroundColor property of NSTableRowView instead of overriding -drawBackgroundInRect:.

If you do need this override for further customization, I noticed that you're forgetting to call [super drawBackgroundInRect:dirtyRect] in your implementation, which is likely responsible for the behaviour you're seeing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top