NSAttributedString superscript styling

The following code seems to do the trick:

UIFont *fnt = [UIFont fontWithName:@"Helvetica" size:20.0];

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"GGG®GGG"
                                                                                     attributes:@{NSFontAttributeName: [fnt fontWithSize:20]}];
[attributedString setAttributes:@{NSFontAttributeName : [fnt fontWithSize:10]
                                  , NSBaselineOffsetAttributeName : @10} range:NSMakeRange(3, 1)];

enter image description here

Leave a Comment