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 富文本改颜色
本文链接:https://www.haomeiwen.com/subject/rwdamktx.html
网友评论