//Raw Data StringNSString *string=@"I'm a good guy, I'm a good guy, I'm a good guy, Goose Goose Goose Goose Goose , and I'm so, whoa, whoa."; //creating a mutable attributed stringnsmutableattributedstring *attrstring = [[Nsmutableattributedstring alloc] initwithstring:string]; //change the 10-digit font in the string from the 18th position backwardsUifont *smallfont = [Uifont systemfontofsize: -]; [Attrstring addattribute:nsfontattributename Value:smallfont Range:nsmakerange (5,Ten)]; //change the color of the first "1" in a stringUicolor *rcolor =[Uicolor Redcolor]; [Attrstring addattribute:nsforegroundcolorattributename Value:rcolor range:[
stringRangeofstring:@"is a"]]; UILabel*label = [[UILabel alloc] Initwithframe:cgrectmake ( -, -, the, $)]; Label.numberoflines=0; [Self.view Addsubview:label]; Label.attributedtext= attrstring;
Nsmutableattributedstring Variable String usage