码迷,mamicode.com
首页 > 其他好文 > 详细

TTTAtibutedlabel

时间:2018-08-14 14:25:54      阅读:212      评论:0      收藏:0      [点我收藏+]

标签: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;
     }];

TTTAtibutedlabel

标签:inf   add   table   length   ext   uicolor   neu   can   nsstring   

原文地址:https://www.cnblogs.com/guligei/p/9473467.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!