I'm off to a good start. But I would like to make this code more dynamic.
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:string];
UIFont *font = [UIFont systemFontOfSize:10.0f];
UIFont *smallFont = [UIFont systemFontOfSize:9.0f];
[attString beginEditing];
[attString addAttribute:NSFontAttributeName value:(font) range:NSMakeRange(0, string.length - 2)];
[attString addAttribute:NSFontAttributeName value:(smallFont) range:NSMakeRange(string.length - 1, 1)];
Say I have the following String:
@"C3OC2OH4"
I would like to adjust the font size of the numbers only to fulfill a chemistry application. How can I scan the above string, and create a series of custom ranges to plug into my function above, which adjusts the font size?