Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSForegroundColorAttributeName key in iPhone

I heard that NSAttributedString is added in iPhone but when I use the key NSForegroundColorAttributeName for setting the color i get an error saying "NSForegroundColorAttributeName undeclared". Am I missing anything? Please help me.

Regards

Yallappa

like image 986
YPK Avatar asked Dec 01 '22 09:12

YPK


1 Answers

I ran into the same issue as BarretJ mentioned you use the kCTForegroundColorAttributeName constant. Here is an example:

NSMutableAttributedString* attrStr = [[NSMutableAttributedString alloc] initWithString:countStr attributes:nil];

[attrStr addAttribute:(NSString*)kCTForegroundColorAttributeName 
                value:(id)[[UIColor greenColor] CGColor]
                range:range];
like image 114
ribeto Avatar answered Dec 06 '22 00:12

ribeto