I have an iOS UILabel that needs some of the text to be normal and some of the text to be bold. The bold text is actually supposed to be a link to another part of the app, but for now, I'm just reacting to tapping on the entire label. How can I format some of the text to be bold?
Asked
Active
Viewed 1,236 times
2 Answers
1
Use the attributedText
property:
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"This is a test."];
[text addAttribute:NSFontAttributeName
value:[UIFont boldSystemFontOfSize:12]
range:NSMakeRange(0, 4)];
label.attributedText = text;

Glorfindel
- 21,988
- 13
- 81
- 109
0
You need to use NSAttributedString. Please look at this answer to see an example: Any way to bold part of a NSString?