美文网首页
iOS 区间设置字符串

iOS 区间设置字符串

作者: 花蕊1235 | 来源:发表于2017-12-27 14:45 被阅读0次

    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 区间设置字符串

          本文链接:https://www.haomeiwen.com/subject/hvjugxtx.html