How to make round cornered NSTableView rows?

You need to subclass NSTableview and override -highlightSelectionInClipRect: method.

It can be done like this:

Change your tableView's highlighting mode from regular to Source list in Attributes Inspector:

And now subclass NSTableView like this:

-(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]; } } }

Result:

你可能感兴趣的:(How to make round cornered NSTableView rows?)