我正在尝试在选择表行时实现自定义行颜色.
-(void)tableViewSelectionDidChange:(NSNotification *)notification{
NSInteger selectedRow = [_mainTable selectedRow];
NSTableCellView *cell = [_mainTable rowViewAtRow:selectedRow makeIfNecessary:NO];
cell.layer.backgroundColor = [NSColor redColor].CGColor;
NSLog(@"selected");
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用.我发现Apple文档很混乱(也许我错了).我对Mac编程没有经验.
有人建议任何解决方案?基本上我需要选择颜色是透明的.