I have noticed that when my view-based NSTableView
has the highlight
attribute set to "Source List" in Interface Builder, it renders its background with the vibrance effect (i.e., it blurs what lies behind its parent window).
If instead I you set said attribute to "None" or "Regular" (the other two options), the background color
attribute is automatically set to white, and at runtime its rendered opaque (even if a custom color with an alpha of less than 1.0 is specified).
I need my table cells to be non-highlightable, but I would really like the blur effect.
Also, I can't afford disallowing cell highlighting via the NSTableViewDelegate method:
func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool
...because that makes the text fields inside my cells unselectable and thus uneditable.
I found this question, which basically asks for the opposite solution (i.e., disable vibrance when highlight is set "Source List"), so following the answers there I tried this code on the view controller that hosts my table view:
override func viewDidLoad() {
super.viewDidLoad()
// Do view setup here.
let appearance = NSAppearance(named: NSAppearanceNameVibrantLight)
tableView.appearance = appearance
}
(appearance is instantiated and assigned in two separate lines to confirm it is non-nil on the debugger)
...but it doesn't change anything.
Is there any easy workaround?
In Interface Builder, I had to do three things:
…then I was able to see the NSVisualEffectView
that I'd placed the table inside.