NSTableCellView的自定义背景颜色

问题描述:

我想创建一个自定义的NSTableCellView。我subclassed NSTableCellView,我需要有一个自定义背景颜色和高亮/选择颜色。有没有办法做到这一点?NSTableCellView的自定义背景颜色

背景以及选择由NSTableRowView视图处理。它可以(部分)被单元覆盖,但这不是它应该如何。

实现自定义rowview并返回你需要画

@interface MyRowView : NSTableRowView 

那里排座椅后面使用您有:

  • drawBackgroundInRect:
  • drawDraggingDestinationFeedbackInRect:
  • drawSelectionInRect:
  • drawSeparatorInRect:

例如

@implementation MyRowView 

- (void)drawSelectionInRect:(NSRect)dirtyRect { 
     [currentFill fillRect:dirtyRect inContext:[[NSGraphicsContext currentContext]graphicsPort]]; 
} 

@end 

SRC:http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSTableRowView_Class/Reference/Reference.html

+0

的示例使用CPTFill到BTW绘制填充 – 2013-05-04 07:57:07

+0

的OP要求NSTableCellView – 2014-09-24 15:34:21

+0

是和我说:“背景,以及选择由NSTableRowView视图处理它CAN(部分)被单元覆盖,但这不是它应该如何。“ – 2014-09-24 15:35:24