Comment mettre en gras certains mots dans mon UITextView en utilisant NSMutableAttributedString?

J'ai un UITextView et il y a certains mots que je suis casting avec NSString stringWithFormat que je voudrais être en caractères gras.

J'ai regardé autour de Débordement de Pile et essayé de suivre les affectations mais je suppose que je ne suis pas le comprendre.

Voici ce que j'ai été jouer avec:

    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];

source d'informationauteur May Yang