- (void) Setrichnumberwithlabel: (UILabel *) label Color: (Uicolor *) Color FontSize: (cgfloat) size{//Converts the text of a label to NsmutalbeattributedstringNsmutableattributedstring *attributedstring =[[nsmutableattributedstring alloc]initwithstring:label.text];//defining an empty stringNSString *temp =Nil;//loop based on the length of the property string for(inti =0; i < [attributedstring length]; i++){//take 1-length strings at a timetemp = [Label.text substringwithrange:nsmakerange (I,1)];//The length of the string is interpreted to include numbers and punctuation. if([Temp isequaltostring:@"0"] || [Temp isequaltostring:@"1"] || [Temp isequaltostring:@"2"] || [Temp isequaltostring:@"3"] || [Temp isequaltostring:@"4"] || [Temp isequaltostring:@"5"] || [Temp isequaltostring:@"6"] || [Temp isequaltostring:@"7"] || [Temp isequaltostring:@"8"] || [Temp isequaltostring:@"9"]|| [Temp isequaltostring:@"."] || [Temp isequaltostring:@"-"]){//add a color to a qualifying property string, font[attributedstring setattributes:[nsdictionary Dictionarywithobjectsandkeys:color,
Nsforegroundcolorattributename, [Uifont Fontwithname:font_lanting_jianhei size:size],
Nsfontattributename, Nil] range:nsmakerange (i,1)]; } }//re-pass the text of the label to the property string that is handled wellLabel.attributedtext =attributedstring;}
IOS same Uilabel change the color of numbers