简体   繁体   中英

How can I change the background of a NSTableColumn?

I need to change the background of specific columns in my NSTableView (on mac).

Should I change it at column level or cell level?

thanks

You can change the color for each of the cells in that column. Something kind of like:

- (NSView*)tableView:(NSTableView*)tableView viewForTableColumn:(NSTableColumn*)tableColumn
              row:(NSInteger)row
{
    //make cell
    ...
    if([tableColumn.identifier isEqual:@(0))
    {
        cellView.drawsBackground = YES;
        cellView.backgroundColor = [NSColor lightGrayColor];
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM