これは私が以前考えていたように簡単ではありません:NStableviewにはいくつかの問題があります。次のようなものを使用している場合:
[destinationsListForSaleTableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
あなたはしなければならない
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
if ([[aTableView selectedRowIndexes] containsIndex:rowIndex]) {
[aCell setBackgroundColor: [NSColor colorWithDeviceRed:0.29 green:0.27 blue:0.42 alpha:1]];
} else [aCell setBackgroundColor: [NSColor colorWithDeviceRed:0.52 green:0.54 blue:0.70 alpha:1]];
[aCell setDrawsBackground:YES];
}
uセルがカスタムでない場合は、これで十分です。高さと内部を変更する場合は、より複雑にする必要があります。
あなたの選択のために選択スタイルテーブルを保管してください。セルサブクラス:
-(NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
return nil;
//[NSColor colorWithDeviceRed:0.29 green:0.27 blue:0.42 alpha:1];
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
if ([self isHighlighted]) {
[[NSColor colorWithDeviceRed:0.29 green:0.27 blue:0.42 alpha:1] set];
cellFrame.origin.x -= 1;
cellFrame.origin.y -= 1;
cellFrame.size.height += 2;
cellFrame.size.width += 3;
NSRectFill(cellFrame);
}
[super drawWithFrame:cellFrame inView:controlView];
}
なぜ詰め物のサイズを変えるのかと聞かれますか?バックグラウンドを使用する場合、アップルは小さなボックスを残します。これは異なる色になります。