Reputation: 111
Sorry this is a noob question but I am a noob so I hope that is ok.
Say I have a label that displays this:
"I am a Label"
is it possible to make just the word "Label" bold or change its color?
thanks!
Upvotes: 1
Views: 5219
Reputation: 660
UILabel can't support attribute. So you should use the NSAttributedString class.
For example:
NSMutableAttributedString * string = [[NSMutableAttributedString alloc] initWithString:@"I am a Label"];
[string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(7,5)];
Then draw the AttributedString to the view in the drawRect method.
Upvotes: 4
Reputation: 4732
you can not do this with usual lable. Override it, or, if your text is static, use several labels, with diferent text styles. If it's just a background for something, you may put there a picture with this text
Upvotes: 0
Reputation: 6268
You can't do this directly by using the Apple frameworks and classes. But, you could do this by using the TTAttributedLabel classes. You can find the project at the below mentioned link, https://github.com/mattt/TTTAttributedLabel
Upvotes: 1