0
votes

I have a very standard NSTableView (this is Mac, not iOS) with a few text rows. Each row is an NSTextField. I was unhappy with the border of the text fields (see image) so I removed it. However doing so the selected cells look weird.

How can I fix that?

before: enter image description here

after enter image description here

Note:

- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row  {
    NSTextField *cell = [tableView makeViewWithIdentifier:@"MyView" owner:self];
    if (cell == nil) {
        cell = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, tableView.bounds.size.width, 30)];
        cell.identifier = @"MyView";
        cell.editable = NO;
        cell.bordered = NO;
    }
    cell.stringValue = [NSString stringWithFormat:@"row %d", row];
    return cell;
}

I have tried to set cell.selectable = YES but it didn't help. I have also tried to play with some properties on the storyboard ("focus ring", ...) but it didn't work either. Any idea?

1

1 Answers

0
votes

Setting cell.backgroundColor = [NSColor clearColor]; did the trick (transparent background)