Change selection color on view-based NSTableView

前端 未结 13 1997
别跟我提以往
别跟我提以往 2020-12-07 19:11

Standard highlighting color in OS X applications is blue.

Is it possible to change it to another color, e.g. gray?

Note that I am using the new view-based

相关标签:
13条回答
  • 2020-12-07 19:38
    - (void)tableViewSelectionDidChange:(NSNotification *)notification
    {
        [tblCategory enumerateAvailableRowViewsUsingBlock:^(NSTableRowView *rowView, NSInteger row){
            CustomMainCell *cellView = [rowView viewAtColumn:0];
            if(rowView.selected){
                cellView.txtFieldTitle.textColor=[NSColor colorWithCalibratedRed:245.0/255.0 green:110.0/255.0 blue:65.0/255.0 alpha:1.0];
            }else{
                cellView.txtFieldTitle.textColor=[NSColor whiteColor];
            }
        }];
    }
    

    [tblCategory setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];

    0 讨论(0)
提交回复
热议问题