How do I set the column margins in an NSTableView?
I would like to add more padding to the column margins in my NSTableV开发者_高级运维iew (ie. more gap between the left side of the column and the column text).
Calling setIntercellSpacing does the trick for the rows, but it leaves the column heading margin unaffected. Can anyone offer a solution?
Thanks
I'll first say it's a little weird to have margins between table column header cell text, but that's just my opinion.
There's no API-supported way to do this exact thing as far as I know. You can probably achieve the effect by asking the column for its header cell (which is a subclass of NSTextFieldCell), setting its attributed string value ( via -setAttributedStringValue: ). You might have to also set -setAllowsEditingTextAttributes: to YES but I'm not sure.
The alternative is to subclass NSTableHeaderCell and override -titleRectForBounds: to pass a width-inset copy of the rectangle super returns. You'd then have to replace the columns' header cells via -setHeaderCell:.
精彩评论