How do I set the color of an NSButtonCell's label (title) text, that is the column cell for a table view? In my case, it is an checkbox button cell. (Is it possible using IB?)
UIColor? That's Cocoa Touch. The questioner is asking about NSButtonCell, which is a Cocoa class.
Peter Hosey
2010-10-14 15:51:01
+1
A:
You could try an attributed string value.
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]];
Pierre Bernard
2010-10-14 14:37:21
You can pass `0.0` for the size to get the default regular size. You can also ask NSFont for any of the other sizes (e.g., the size for Small controls and cells). You generally should not pass an explicit size.
Peter Hosey
2010-10-14 15:53:22