标签:inf add table length ext uicolor neu can nsstring
NSString *rateStr = [NSString stringWithFormat:@"七日年化 %.2f%%",info.rate];
[self.rateLabel setText:rateStr afterInheritingLabelAttributesAndConfiguringWithBlock:
^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
[mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor blueColor] range:NSMakeRange(0, 4)]; //loc + length
[mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor redColor] range:NSMakeRange(4, rateStr.length-4)];
[mutableAttributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue" size:17.0] range:NSMakeRange(4, rateStr.length-4)];
return mutableAttributedString;
}];
标签:inf add table length ext uicolor neu can nsstring
原文地址:https://www.cnblogs.com/guligei/p/9473467.html