You can achieve this by doing it programatically. Use NSMutableAttributedString
NSMutableAttributedString *stringText = [[NSMutableAttributedString alloc] initWithString:@"This is awesome"];
//Green color for the first four characters.
[stringText addAttribute: NSForegroundColorAttributeName value: [UIColor greenColor] range: NSMakeRange(0, 4)];
// Sets the font color of last four characters to yellow.
[stringText addAttribute: NSForegroundColorAttributeName value: [UIColor yellowColor] range: NSMakeRange(14, 10)];
Set this text to your UITextView. It should work. Also make sure if text changes dynamically you need to care full with NSMakeRange.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.