2

我正在尝试创建一个自定义 NSTableCellView。我对 NSTableCellView 进行了子类化,并且需要自定义背景颜色和突出显示/选择颜色。有没有办法做到这一点?

4

1 回答 1

2

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

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

@interface MyRowView : NSTableRowView

你有:

  • 绘制背景矩形:
  • 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

于 2013-05-04T07:50:27.370 回答