NSMutableAttributedString富文本,文字大小不同默认底部是对齐的
NSString *number = @"983元";
NSInteger length = number.length - 1;
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:number];
[str addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:52] range:NSMakeRange(0, length)];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:NSMakeRange(length, 1)];
[str addAttribute:NSBaselineOffsetAttributeName value:@(10) range:NSMakeRange(length, 1)];//元 上移10 value值越大 越靠上
[str addAttribute:NSKernAttributeName value:@(3) range:NSMakeRange(number.length - 2, 1)];//修改“元”距离数字的距离 value 是正值 值越大数字和元里的越远 负值 值越距离越近
name.attributedText = str;
NSBaselineOffsetAttributeName用于更改NSTextAttachment的基线.