Hi,
I am looking for a way to change the text color for all cells in a row to red if the value of a certain value in that row is < 0.
I am using a NSTableView, an Array Controller and Bindings to populate the table.
Any ideas?
Max
Founds this one and it seems to do the trick 🙂
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
if let myCell:NSTableCellView = tableView.make(withIdentifier: (tableColumn?.identifier)!, owner: self) as! NSTableCellView {
let value = transactions[row].amount
if (value >= 0) {
myCell.textField?.textColor = NSColor.green
} else {
myCell.textField?.textColor = NSColor.red
}
return myCell
}
}