我有一个非常标准的NSTableView(这是Mac,而不是iOS),其中包含一些文本行。每行是一个NSTextField。我对文本字段的边框不满意(参见图片),因此将其删除。但是这样做,所选单元格看起来很奇怪。
我该如何解决?
注意:
- (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;
}
我尝试设置cell.selectable = YES
,但没有帮助。我也尝试过在情节提要中使用某些属性(“对焦环”,...),但是它也不起作用。有什么主意吗?
设置cell.backgroundColor = [NSColor clearColor];
完成了trick俩(透明背景)