iOS 同一段文字显示不同颜色

iOS开发-同一段文字显示不同颜色

http://blog.csdn.net/codingfire/article/details/50395838

 

NSString *testStr = @"当前可提现金额3000.00元";

NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:testStr];

[str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.27f green:0.61f blue:1.00f alpha:1.00f] range:NSMakeRange(7,testStr.length - 8)]; [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(7,testStr.length - 8)];

tixianLabel.attributedText = str;

posted @ 2018-01-30 15:54  small英  阅读(490)  评论(0编辑  收藏  举报