0

Especially in NSTableHeaderCell, in drawInterior, I have set in func drawInterior to draw the background with "clear" color to make it transparent(with NSVisualEffect added to clipView)

but there are some places(outside interior) that still use opaque color in NSTableHeaderCell.

class MyHeaderCell: NSTableHeaderCell {

        override func drawInterior(withFrame cellFrame: NSRect, in controlView: NSView) {
            let adjustedFrame = NSRect(x: cellFrame.origin.x + 1, y: cellFrame.origin.y + 1, width: cellFrame.size.width - 4.9, height: cellFrame.size.height)
            NSColor.clear.setFill()
            adjustedFrame.fill(using: .clear)
            super.drawInterior(withFrame: adjustedFrame, in: controlView)
        }
    }

**NOTE: this issue only exists on macOS below 10.14.
**

NSTableHeaderView become fully transparent background when i did not call super.draw(withFrame: cellFrame, in: controlView) in func draw(withFrame cellFrame: NSRect, in controlView: NSView) at NSTableHeaderCell subclass. But NSTableHeaderCell lost it separator between each table columns.

override func draw(withFrame cellFrame: NSRect, in controlView: NSView) {
        NSColor.clear.setFill()
        cellFrame.fill(using: .clear)
        super.draw(withFrame: cellFrame, in: controlView)
    }

Screenshot

5
  • How can we reproduce the issue?
    – Willeke
    Commented Dec 5 at 18:21
  • inside the interior of NSTableHeaderCell the background can already be transparent. but between the interiors the background still uses opaque color.I know this because of the call to super.draw(withFrame:in:) inside func draw(withFrame:in:). when not calling super.draw(withFrame:in:), NSTableHeaderCell is fully transparent, but there is no drawing separator between each table column.
    – dsx
    Commented Dec 5 at 18:34
  • Post a minimal reproducible example please.
    – Willeke
    Commented Dec 5 at 18:38
  • Ok. post edited.
    – dsx
    Commented Dec 5 at 18:49
  • This question is similar to: How can I create a transparent NSTableHeaderView for a black HUD window?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.
    – Willeke
    Commented Dec 5 at 19:22

0