我想做这样的事情(在新的 iTunes 上):
As you can see when the row is selected it's "highlight" state is a round cornered row.
我怎样才能实现这样的目标?
我想做这样的事情(在新的 iTunes 上):
As you can see when the row is selected it's "highlight" state is a round cornered row.
我怎样才能实现这样的目标?
您需要子类化NSTableview
和覆盖-highlightSelectionInClipRect:
方法。
可以这样做:
在Attributes Inspector中将tableView 的突出显示模式从常规更改为Source 列表:
现在NSTableView
像这样子类:
-(void)highlightSelectionInClipRect:(NSRect)theClipRect
{
NSRange visibleRowIndexes = [self rowsInRect:theClipRect];
NSIndexSet *selectedRowIndexes = [self selectedRowIndexes];
NSUInteger endRow = visibleRowIndexes.location + visibleRowIndexes.length;
NSUInteger row;
for (row=visibleRowIndexes.location; row<endRow; row++)
{
if([selectedRowIndexes containsIndex:row])
{
NSRect rowRect = NSInsetRect([self rectOfRow:row], 3, 4);
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:rowRect xRadius:4.0 yRadius:4.0];
[[NSColor colorWithCalibratedRed:0.474 green:0.588 blue:0.743 alpha:1] set];
[path fill];
}
}
}
结果: