在我的大纲视图中,我使用的是CustomCell,它只不过是从Cocoa ImageTextCell RefrenceCode中提取代码,并进行了一些修改,
是否可以更改单元格的突出显示颜色?
到目前为止,我已经完成了以下操作:- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
if([self isHighlighted]){
NSColor *evenColor = [NSColor colorWithCalibratedRed:.1 green:0.1 blue: 0.1
alpha:1.0];
[evenColor set];
NSRectFill(cellFrame);
bSelected = YES;
}}
我可以看到,高亮的单元格颜色首先从系统默认颜色开始,然后,它将被evenColor覆盖,我觉得问题出在cellFrame.origin.x,它不是从0开始的,
应用这段代码后,输出如下
----- My Custom Cell ----------------
======================================
| blue | |
| color| even Color |
| | |
======================================以及我所期待的
----- My Custom Cell ----------------
======================================
| |
| even Color |
| |
======================================发布于 2011-02-08 06:30:12
高亮显示由NSOutlineView处理(实际上,它是从NSTableView继承的行为)。无论如何,与其关注单元格,不如看看对NSOutlineView进行子类化和重写highlightSelectionInClipRect:。这就是你应该做自定义高光绘制的地方。
https://stackoverflow.com/questions/4926986
复制相似问题