UILabel* lbl = [[UILabel alloc] init];
NSString* str = [NSString stringWithFormat:@"%@ %@", repeat, item.remember];
NSMutableAttributedString* aStr = [[NSMutableAttributedString alloc] initWithString:str];
[aStr addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:14],
NSFontAttributeName,
[UIColor blackColor],
NSForegroundColorAttributeName,
nil]
range:[str rangeOfString:repeat]];
[aStr addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:14],
NSFontAttributeName,
RGBCOLOR(188, 188, 188),
NSForegroundColorAttributeName,
nil]
range:[str rangeOfString:item.remember]];
lbl.attributedText = aStr;
IOS系统原生富文本
最新推荐文章于 2021-09-25 22:28:46 发布