Rag*_*hav 7 macos cocoa objective-c nstableview
我正在开发一个MAC应用程序并包含tableView.想要将所选行的颜色更改为黄色.
Neh*_*eha 14
在表视图上设置:
[yourtableview setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
Run Code Online (Sandbox Code Playgroud)
并实现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];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7421 次 |
| 最近记录: |