Reputation: 305
I try to add string with different colors in my UITextView. I wrote this code
NSMutableAttributedString* attString =
[[NSMutableAttributedString alloc]initWithString:view.text]; //view is my UITextView
[attString addAttribute:(NSString*)kCTForegroundColorAttributeName
value:[UIColor greenColor]
range:(NSRange){attString.length-8, 8}];
view.attributedText = attString;
Maybe it is incorrect attribute, can you tell me what attribute change color for text?
Upvotes: 1
Views: 1572
Reputation: 385540
Try using NSForegroundColorAttributeName
instead of kCTForegroundColorAttributeName
.
NSAttributedString attribute keys
Upvotes: 3