【发布时间】:2017-02-24 17:20:56
【问题描述】:
我使用NSTableView 来显示我的数据。我想删除默认采用blue color 的选定行的颜色。我可以将其设置为Clear color。可以吗??
编辑:
我怎样才能去掉这个蓝色边框??我已将Clear color 设置为表格背景。
提前致谢..!!! :)
【问题讨论】:
标签: cocoa xcode4 nstableview nscolor
我使用NSTableView 来显示我的数据。我想删除默认采用blue color 的选定行的颜色。我可以将其设置为Clear color。可以吗??
编辑:
我怎样才能去掉这个蓝色边框??我已将Clear color 设置为表格背景。
提前致谢..!!! :)
【问题讨论】:
标签: cocoa xcode4 nstableview nscolor
[tableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
要移除表格的蓝色焦点环边框,请在 .XIB 中选择表格并将焦点环设置为无
【讨论】:
这条线应该去掉环。
[tableView setFocusRingType:NSFocusRingTypeNone];
【讨论】:
@Snhl Francis McGrew 说“选择 .XIB 中的表格并将 Focus Ring 设置为 None”,该表格在 Scroll View 内
【讨论】:
这样就可以了:)
[结果集可选:否];
把上面的代码放到下面的方法中...
- (NSView *)tableView:(NSTableView *)tableView
viewForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row {
NSTextField *result = [tableView makeViewWithIdentifier:@"MyView" owner:self];
// There is no existing cell to reuse so create a new one
if (result == nil) {
result = [[NSTextField alloc] initWithFrame:CGRectMake(0, 0, 289, 50)];
result.identifier = @"MyView";
}
[result setBackgroundColor:[NSColor clearColor]];
[result setBordered:NO];
//set selectable proeprty to NO and your blue border will disappear
[result setSelectable:NO];
// Return the result
return result;
}
【讨论】: