My Cocoa app has a view-based table view.
The table displays a week of the calendar, where each column is a day from (say) Sunday to Saturday.
I would like to highlight the column that corresponds to "Today" in some way; ideally, give a colored background to the textfield, with rounded corners; something like this:
(this is trivial to achieve in iOS. On macOS, with cells etc. instead of views and layers, everything seems so much more complicated...)
However, I am not even able to change the header cell's text or background color. The code below (Swift 3) is executed, however all column headers is displayed with the default colors :
let columns = tableView.tableColumns
// (currentWeek is an array of NSDate)
for (index, day) in currentWeek.enumerated() {
let column = columns[sundayIndex + index]
if Shared.calendar.isDateInToday(day) {
// THESE TWO LINES ARE EXECUTED, BUT...
column.headerCell.textColor = NSColor.red
// ...NO EFFECT
column.headerCell.backgroundColor = NSColor.black
// ...NO EFFECT
}
// THIS WORKS FOR EVERY ROW:
column.headerCell.stringValue = formatter.string(from: day)
}