Search code examples
objective-ccocoaappkitnscolor

How does Mac OS X Finder determine header color?


I am designing a table-like control using Cocoa/Objective-C. Since I want to emulate the look of Finder on Mac, I retrieve system colors when drawing my table.

In particular, use [NSColor controlAlternatingRowBackgroundColors] for the table rows, which looks reasonably good in my opinion. However, when it comes to the table headers, I have some issues:

[NSColor headerTextColor] yields a black color (which is fine for me, since Finder's header captions are black, as well), but I expected [NSColor headerColor] to yield a color against which the text can be read well. However, [NSColor headerColor] yields a pretty dark gray - obviously differing from Finder's header color.

So, is it normal for headerColor to be that dark? How does Finder determine its header colors (is this even documented)?


Solution

  • Table view headers in Finder haven't been a solid color since before Mac OS X 10.0. First they were "lickable" Aqua blue (or white, unselected) gradients, then they got a bit flatter over time, and since Yosemite (10.10) they've used the blurry translucent effect that's otherwise accessible to developers as NSVisualEffectView.

    In any case, headerColor and several other NSColor system colors (like gridColor) don't reflect current UI designs. It's probably worth filing a bug to Apple about either deprecating the methods, mentioning in the documentation exactly which colors are still used for what, or both.

    If you want headers that match Finder, and you're not using NSTableView (which gets them for free), NSVisualEffectView is probably what you want.