ios 富文本改颜色

2020-10-26  本文已影响0人  biubiuboom
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];
上一篇 下一篇

猜你喜欢

热点阅读