下面这段,亲试可用

/*将符号转换为上标*/

-(NSMutableAttributedString *)changeToSuperscriptForNumberSignWith:(NSString *)string changeString:(NSString *)changeString{

NSRange range = [string rangeOfString:changeString];

NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc]initWithString:string];

NSDictionary * attris = @{NSBaselineOffsetAttributeName:@(3),

NSFontAttributeName:[UIFont systemFontOfSize:9]};

[attributedString setAttributes:attris range:range];

return attributedString;

}

05-08 07:59