我正在开发一个MAC应用程序,并包括tableView。要将所选行的颜色更改为黄色。
在表格视图上进行设置:
[yourtableview setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
并将NSTableView的以下委托方法实现为:
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
if ([[aTableView selectedRowIndexes] containsIndex:rowIndex])
{
[aCell setBackgroundColor: [NSColor yellowColor]];
}
else
{
[aCell setBackgroundColor: [NSColor whiteColor]];
}
[aCell setDrawsBackground:YES];
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句