美文网首页
ios 富文本改颜色

ios 富文本改颜色

作者: biubiuboom | 来源:发表于2020-10-26 12:01 被阅读0次
NSMutableAttributedString *attribut = [[NSMutableAttributedString alloc]initWithString:str];
       //目的是想改变 ‘/’前面的字体的属性,所以找到目标的range
       NSRange range = [str rangeOfString:guessAccountInfo[@"amount"]];
       NSRange pointRange = NSMakeRange(range.location, [NSString stringWithFormat:@"%@",guessAccountInfo[@"amount"]].length);
       NSMutableDictionary *dic = [NSMutableDictionary dictionary];
       dic[NSForegroundColorAttributeName] = UIColorFromRGB(0xF7FF00);
       //赋值
       [attribut addAttributes:dic range:pointRange];

相关文章

网友评论

      本文标题:ios 富文本改颜色

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