IOS 区间设置字符串

NSString*moneyStr =[NSStringstringWithFormat:@"余额¥ %.2lf"

,moneyValue];

NSMutableAttributedString*attributedStr =[[NSMutableAttributedStringalloc]initWithString

:moneyStr];

[attributedStr

addAttribute:NSFontAttributeNamevalue:[UIFontfontWithName:@"Helvetica-Bold"size:16.0]range:NSMakeRange(0,3

)];

[attributedStr

addAttribute:NSFontAttributeNamevalue:[UIFontfontWithName:@"Helvetica-Bold"size:20.0]range:NSMakeRange(3,1

)];

[attributedStr

addAttribute:NSFontAttributeNamevalue:[UIFontfontWithName:@"Helvetica-Bold"size:50.0]range:NSMakeRange(5,moneyStr.length-5

)];

moneyLable.

attributedText=attributedStr;

你可能感兴趣的:(IOS 区间设置字符串)