【问题标题】:NStableView selected row color (remove border of NSTableView on selection)NStableView 选定的行颜色(在选择时删除 NSTableView 的边框)
【发布时间】:2017-02-24 17:20:56
【问题描述】:

我使用NSTableView 来显示我的数据。我想删除默认采用blue color 的选定行的颜色。我可以将其设置为Clear color。可以吗??

编辑:

我怎样才能去掉这个蓝色边框??我已将Clear color 设置为表格背景。


提前致谢..!!! :)

【问题讨论】:

    标签: cocoa xcode4 nstableview nscolor


    【解决方案1】:
    [tableView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleNone];
    

    要移除表格的蓝色焦点环边框,请在 .XIB 中选择表格并将焦点环设置为无

    【讨论】:

    • 谢谢它很好用..!!:) 但是表格边框仍然突出显示.. 是否也可以删除它??
    • @Francis:请编辑/更新您的答案。由于它被接受为“正确”(但不是),因此将来知道OP的问题是对焦环而不是选择突出显示样式会更好地帮助那些人。 :-)
    【解决方案2】:

    这条线应该去掉环。

    [tableView setFocusRingType:NSFocusRingTypeNone];

    【讨论】:

      【解决方案3】:

      @Snhl Francis McGrew 说“选择 .XIB 中的表格并将 Focus Ring 设置为 None”,该表格在 Scroll View 内

      【讨论】:

        【解决方案4】:

        这样就可以了:)

        [结果集可选:否];

        把上面的代码放到下面的方法中...

        - (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;
        
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-06-14
          • 1970-01-01
          • 1970-01-01
          • 2017-03-24
          • 2012-03-16
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多