What I found to work best for me so far is the following code. Just fool the original grid drawing code to draw only on populated rows.
Subclass NSTableView, if needed, and override drawGridInClipRect:(NSRect)clipRect as following:
- (void)drawGridInClipRect:(NSRect)clipRect
{
NSRect lastRowRect = [self rectOfRow:[self numberOfRows]-1];
NSRect myClipRect = NSMakeRect(0, 0, lastRowRect.size.width, NSMaxY(lastRowRect));
NSRect finalClipRect = NSIntersectionRect(clipRect, myClipRect);
[super drawGridInClipRect:finalClipRect];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…