views:

29

answers:

2

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?)

A: 

Can you try someLabel.text.textColor = [UIColor blueColor];

Hari
UIColor? That's Cocoa Touch. The questioner is asking about NSButtonCell, which is a Cocoa class.
Peter Hosey
+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
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