Fabio
Fabio

Reputation: 1973

UITextView how edit some strings programatically?

I am using this code in UITextView

nsstring *var = @"2013 11 30 this is an example";

    NSRange isRange30Nov = [fechaHorarios rangeOfString:@"20131130" options:NSCaseInsensitiveSearch];
    if(isRange30Nov.location == 0) {
        // FOUND
    }

And need change to bold only the date in my UITextView how can i do? thanks!!

Upvotes: 1

Views: 49

Answers (1)

Antonio MG
Antonio MG

Reputation: 20410

You can do that using attributed strings:

    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:var];

    [attrString beginEditing];
    [attrString addAttribute:NSFontAttributeName
                       value:myFontBold
                       range:isRange30Nov];

    [attrString endEditing];

Upvotes: 3

Related Questions