ios 富文本改颜色

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 富文本改颜色)