OS X应用程序中的标准高亮 colored颜色 为蓝色.
是否可以将其更改为其他 colored颜色 ,例如灰色?
请注意,我使用的是从OS X 10.7开始提供的新的基于视图的NSTableView
.
OS X应用程序中的标准高亮 colored颜色 为蓝色.
是否可以将其更改为其他 colored颜色 ,例如灰色?
请注意,我使用的是从OS X 10.7开始提供的新的基于视图的NSTableView
.
由于使用的是基于视图的NSTableView,因此可以将NSTableRowView子类化,将其提供给表委托方法- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row;
,然后在row view类中自定义 Select .
下面是一个例子:
- (void)drawSelectionInRect:(NSRect)dirtyRect {
if (self.selectionHighlightStyle != NSTableViewSelectionHighlightStyleNone) {
NSRect selectionRect = NSInsetRect(self.bounds, 2.5, 2.5);
[[NSColor colorWithCalibratedWhite:.65 alpha:1.0] setStroke];
[[NSColor colorWithCalibratedWhite:.82 alpha:1.0] setFill];
NSBezierPath *selectionPath = [NSBezierPath bezierPathWithRoundedRect:selectionRect xRadius:6 yRadius:6];
[selectionPath fill];
[selectionPath stroke];
}
}