Possible Duplicate:
how to set attributes in NSAttributedString in iOS?
I have the following code:
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];
This is however an iOS 6 code, what if I want to do the same in iOS 5. Do I have to use a third party library for this?
You could drop down into Core Text for iOS 5. Core Text is more powerful than
NSAttributedStringbut it’s also less documented and less accessible to engineers.