NSTableCellView的自定义背景颜色

时间:2013-05-03 23:38:17

标签: objective-c cocoa nstableview nstableviewcell

我正在尝试创建自定义NSTableCellView。我将NSTableCellView子类化,我需要自定义背景颜色和高亮/选择颜色。有没有办法做到这一点?

1 个答案:

答案 0 :(得分:2)

背景以及选择由NSTableRowView视图处理。它可以(部分地)被细胞覆盖,但根本不应该如何覆盖它。

实现自定义rowview并将其返回以便在您需要绘制的行后面使用

@interface MyRowView : NSTableRowView
你有:

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

e.g。

@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

相关问题