iOS 区间设置字符串
2017-12-27 本文已影响0人
花蕊1235
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;