如何设置NSButtonCell的标签(标题)文本的颜色,即表格视图的列单元格?在我的例子中,它是复选框按钮单元格。(是否可以使用IB?)
发布于 2013-01-01 20:33:34
试试这个吧,我觉得它很完美。
NSColor *color = [NSColor redColor];
NSMutableAttributedString *colorTitle =
[[NSMutableAttributedString alloc] initWithAttributedString:[button attributedTitle]];
NSRange titleRange = NSMakeRange(0, [colorTitle length]);
[colorTitle addAttribute:NSForegroundColorAttributeName
value:color
range:titleRange];
[button setAttributedTitle:colorTitle];发布于 2010-10-14 22:37:21
你可以尝试一个属性字符串值。
NSColor *txtColor = [NSColor redColor];
NSFont *txtFont = [NSFont boldSystemFontOfSize:14];
NSDictionary *txtDict = [NSDictionary dictionaryWithObjectsAndKeys:
txtFont, NSFontAttributeName, txtColor, NSForegroundColorAttributeName, nil];
NSAttributedString *attrStr = [[[NSAttributedString alloc]
initWithString:@"Hello!" attributes:txtDict] autorelease];
[[attrStrTextField cell] setAttributedStringValue:attrStr];
[attrStrTextField updateCell:[attrStrTextField cell]];https://stackoverflow.com/questions/3932796
复制相似问题