How can I change the color of a cell in my NSTableView?
+1
A:
Try using a custom NSView
for that, or NSTableView
's -setBackgroundColor:
method.
Alexsander Akers
2010-05-21 02:05:44
Glad this helped you! :)
Alexsander Akers
2010-05-28 02:31:25
A:
In your NSTableViewDelegate
for the NSTableView
, implement this method:
- (void)tableView:(NSTableView *)tableView
willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row
The NSTableView
calls this on its delegate before displaying each cell so that you can affect its appearance. Assuming you're using NSTextFieldCells, for the cell that you want to change call:
[cell setBackgroundColor:...];
Or, if you want to change the text color:
[cell setTextColor:...];
If you want columns to have different appearances, or if all of the columns aren't NSTextFieldCells, use [tableColumn identifier]
to, er, identify the column. You can set the identifier in Interface Builder by selecting the table column.
Adam Preble
2010-05-22 01:29:50