カスタム NSTableHeaderCell を使用した NSTableView の背景のクリアに関する問題が発生しました。テーブル列のサイズを変更するとき。
// The method for setting NSTableView in some place
// NSScrollView disabled Draw Background
- (void)setMainTableView:(NSTableView *)mainTableView {
_mainTableView = mainTableView;
[_mainTableView setBackgroundColor:[NSColor clearColor]];
[[_mainTableView tableColumns] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
NSString *columnTitle = [[obj headerCell] stringValue];
MyTableHeaderCell *myCell = [[MyTableHeaderCell alloc] initTextCell:columnTitle];
[obj setHeaderCell:myCell];
}];
}
// Overriding NSTableHeaderCell Method
- (void)drawWithFrame:(CGRect)cellFrame inView:(NSView *)view {
[[NSColor redColor] set];
NSFrameRect(cellFrame);
[super drawInteriorWithFrame:cellFrame inView:view];
}