可能是重复问题:
如何在iOS中设置NSAttributedString的属性?
如何在iOS中设置NSAttributedString的属性?
我有以下代码:
comment = [[NSMutableAttributedString alloc] initWithString:self.highlightItem_.comment];
[comment addAttribute:NSFontAttributeName value:[UIFont fontWithName:kProximaNovaBold size:15] range:nameRange];
[comment addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:128/255.f green:203/255.f blue:255/255.f alpha:1.0] range:nameRange];
[comment addAttribute:NSFontAttributeName value:[UIFont fontWithName:kProximaNova size:15] range:commentRange];
[comment addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithWhite:153/255.f alpha:1.0] range:commentRange];
这是基于iOS 6的代码,如果我想在iOS 5中实现同样的功能,我需要使用第三方库吗?