我正在用我使用 NSAttributedString 格式化的数据填充 NSOutlineView。到目前为止,我已经格式化了文本字体、大小和颜色。我的问题是选择行时前景色不会改变。如果您创建一个Nstextfieldcell并将颜色设置为接口构建器上的禁用ControltextColor,则可以正常工作:当未选择选择时,它是灰色的,当我选择白色时,当我编程将此颜色设置为属性字符串定义时,它总是显示为始终显示为灰色的。
NSMutableAttributedString *result = [[[NSMutableAttributedString alloc] initWithString:value] autorelease];
NSDictionary *attributes = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:[NSFont systemFontSize] -1], NSFontAttributeName,
[NSColor disabledControlTextColor], NSForegroundColorAttributeName, nil] retain];
[result addAttributes:attributes range:[value rangeOfString:value]];
提前致谢。