NSTableCellView的自定义背景色 [英] Custom background colors for NSTableCellView

查看:202
本文介绍了NSTableCellView的自定义背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建自定义NSTableCellView。我将NSTableCellView划分为子类,我需要具有自定义的背景颜色和突出显示/选择颜色。有办法吗?

I am trying to create a custom NSTableCellView. I subclassed NSTableCellView and I need to have a custom background color and highlight/selection color. Is there a way to do this?

推荐答案

背景以及选择由处理NSTableRowView 视图。它可以(部分地)被单元格覆盖,但这根本不是应该的。

the background as well as the selection is handled by the NSTableRowView view. It CAN (partly) be overwritten by the cell but that's not how it should be at all.

实现自定义行视图,并将其返回以供在行后面使用,您需要绘制

Implement a custom rowview and return that for use behind the row you need to draw

@interface MyRowView : NSTableRowView

您有:


  • drawBackgroundInRect:

  • drawDraggingDestinationFeedbackInRect:

  • drawSelectionInRect:

  • drawSeparatorInRect:

  • drawBackgroundInRect:
  • drawDraggingDestinationFeedbackInRect:
  • drawSelectionInRect:
  • drawSeparatorInRect:

例如

@implementation MyRowView

- (void)drawSelectionInRect:(NSRect)dirtyRect {
        [currentFill fillRect:dirtyRect inContext:[[NSGraphicsContext currentContext]graphicsPort]];
}

@end

SRC: http://developer.apple.com/library/mac/ #documentation / Cocoa / Reference / NSTableRowView_Class / Reference / Reference.html

这篇关于NSTableCellView的自定义背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆