我听说在 iPhone 中添加了 NSAttributedString,但是当我使用键 NSForegroundColorAttributeName 设置颜色时,我收到一条错误消息,提示“NSForegroundColorAttributeName undeclared”。我错过了什么吗?请帮我。
问候
亚拉帕
我听说在 iPhone 中添加了 NSAttributedString,但是当我使用键 NSForegroundColorAttributeName 设置颜色时,我收到一条错误消息,提示“NSForegroundColorAttributeName undeclared”。我错过了什么吗?请帮我。
问候
亚拉帕
我遇到了与 BarretJ 提到您使用 kCTForegroundColorAttributeName 常量相同的问题。这是一个例子:
NSMutableAttributedString* attrStr = [[NSMutableAttributedString alloc] initWithString:countStr attributes:nil];
[attrStr addAttribute:(NSString*)kCTForegroundColorAttributeName
value:(id)[[UIColor greenColor] CGColor]
range:range];
尝试改用 kCTForegroundColorAttributeName。