开发者

NSForegroundColorAttributeName key in iPhone

开发者 https://www.devze.com 2023-01-16 07:20 出处:网络
I heard that NSAttributedString is added in iPhone but when I use the key NSForegroundColorAttributeName for setting the color i get an error saying \"NSFore开发者_JS百科groundColorAttributeName undec

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

Regards

Yallappa


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];


Try using kCTForegroundColorAttributeName instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消