objective c - NSTableRowView/NSTableCellView how to set custom color to selected row? -


I'm trying to apply custom row colors when the table row is selected.

  - (zero) tableview selectionde change: (nsnification *) notification {nsintre selected ro = [_mainTable selected ro]; NSTableCellView * cell = [_mainTable rowViewAtRow: selectedRow makeIf required: no]; Cell.layer.backgroundColor = [NSColor redColor] .CGColor; NSLog (@ "selected"); }  

but it is not working I think Apple's documentation is very confusing (maybe I'm wrong) I'm not experienced with Mac programming.

Can anyone recommend a solution? Basically I need this selection color to be transparent.

first set table view selection highlight style

  NSTableViewSelectionHighlightStyleNone  

Then apply in your tablView rep

  TableView: Select:  

and type this code inside:

  UITableViewRow * line = [_mainTable rowViewAtRow: selectedRow makeIfNecessary: ​​NO]; Row.backgroundColor = [your color]; Yes come back  

Read also:

for selection style


Comments