Handling custom selection style in view based NSTableView

后端 未结 2 1927
孤城傲影
孤城傲影 2020-12-18 08:42

How do I go about drawing my own custom selection style for a view based NSTableView? I tried putting a BOOL var in my NSTableCellView

相关标签:
2条回答
  • 2020-12-18 09:12

    To make things clear, I think we should give the code of the delegate method :

    - (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row
    {
       MyNSTableRowView *rowView = [[MyNSTableRowView alloc]init];
       return rowView;
    }
    
    0 讨论(0)
  • 2020-12-18 09:13

    Alright, I figured it out. You just have to subclass NSTableRowView. It has methods for drawing the background for selected and deselected rows. To get the table view to use your subclass just implement the table view delegate method tableView:rowViewForRow: and return an instance of your subclass.

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