Search code examples
macoscocoaappkitnsoutlineview

NSTintConfiguration for NSOutlineView not working


I am trying to change the tint color of some of my items in my NSOutlineView. The delegate method is being called, however the color does not change. Here is what I do:

@available(OSX 11.0, *)
func outlineView(_ outlineView: NSOutlineView, tintConfigurationForItem item: Any) -> NSTintConfiguration? {
    return NSTintConfiguration(fixedColor: NSColor.systemYellow)
}

Solution

  • While writing this question, I've found the answer. Make sure the imageView outlet of the NSTableCellView is connected to the to the NSImageView that is your icon. Otherwise the NSOutlineView does not know what image to colorise. It is connected by default, but I did remove the connection since I did not need it for anything else.