NSTableview更改突出显示颜色 [英] NSTableview Change the highlight colour

查看:148
本文介绍了NSTableview更改突出显示颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个MAC应用程序,并包括tableView。
要将选定行的颜色更改为黄色。

I am developing a MAC application and included the tableView. Want to change the Colour of selected row to yellow.

推荐答案

在表视图上设置:

[yourtableview setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];

并实现NSTableView的以下委托方法:

And implement the following delegate method of NSTableView as:

- (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];
}  

这篇关于NSTableview更改突出显示颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆