我想创建一个包含具有不同颜色文本的标签。与此类似,如何在iOS 5.1及更低版本的UILabel中创建多色文本
我已经在iOS 6中使用NSMutableAttributedString
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithAttributedString: self.exerciseLbl.attributedText];
[text addAttribute: NSForegroundColorAttributeName value: [UIColor colorWithRed:(187/255.0) green:(57/255.0) blue:(38/255.0) alpha:1] range: NSMakeRange(0, 2)];
[self.exerciseLbl setAttributedText: text];
做到了这一点,但这个不会适用于iOS 5.1及以下工作。那么我如何才能在iOS 5中实现相同的结果。
使用属性字符串http://www.cocoanetics.com/2011/01/befriending-core-text/! – rptwsthi