4

我听说在 iPhone 中添加了 NSAttributedString,但是当我使用键 NSForegroundColorAttributeName 设置颜色时,我收到一条错误消息,提示“NSForegroundColorAttributeName undeclared”。我错过了什么吗?请帮我。

问候

亚拉帕

4

2 回答 2

11

我遇到了与 BarretJ 提到您使用 kCTForegroundColorAttributeName 常量相同的问题。这是一个例子:

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

[attrStr addAttribute:(NSString*)kCTForegroundColorAttributeName 
                value:(id)[[UIColor greenColor] CGColor]
                range:range];
于 2010-10-06T15:57:16.123 回答
9

尝试改用 kCTForegroundColorAttributeName。

于 2010-09-23T18:20:29.363 回答