【发布时间】:2013-04-10 13:24:06
【问题描述】:
我创建了一个可变字符串,看起来像 @"testMeIn:greenColor:Different:greencolor:Colors"
NSMutableAttributedString *mutableText = [[NSMutableAttributedString alloc] initWithAttributedString:myString];
UIColor *foregroundColor = [UIColor blackColor];
NSString *key = NSForegroundColorAttributeName;
[mutableText addAttribute:key value:foregroundColor range:NSMakeRange(0, myString.length)];
当我添加属性 foregroundColor 时,子字符串中现有的绿色会被指定的黑色覆盖。虽然我可以更改代码以设置子字符串的绿色,但我想知道是否有任何其他方法可以将样式应用于没有样式而不覆盖现有样式的字符串部分。
【问题讨论】:
标签: objective-c nsattributedstring