¿Cómo poner en negrita algunas palabras en mi UITextView usando NSMutableAttributedString?
Tengo un UITextView y hay ciertas palabras que estoy lanzando con NSString stringWithFormat que me gustaría en negrita.
Miré alrededor de Stack Overflow e intenté seguir las publicaciones, pero supongo que no lo entiendo.
Esto es con lo que he estado jugando:
NSRange boldedRange = NSMakeRange(0, 4);
NSString *boldFontName = [[UIFont fontWithName:@"Helvetica-Bold" size:100]fontName];
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:self.name];
[attrString beginEditing];
[attrString addAttribute:NSFontAttributeName
value:boldFontName
range:boldedRange];
[attrString endEditing];
self.resultsTextView.attributedText = attrString;
self.resultsTextView.text = [NSString stringWithFormat:@"One day, %@ was taking a walk and saw a %@ boy. He was %@ a %@.", attrString, self.adjective, self.adverb, self.noun];