美文网首页
修改字符串中指定字符字体、颜色、大小

修改字符串中指定字符字体、颜色、大小

作者: 小柴2011 | 来源:发表于2017-05-05 14:43 被阅读81次

需求 “20系列 (元)”,“(元)”14号 灰色

UILabel*label1 = [view1addLabel:@"20系列 (元)"Font:kYiZhangTongBaseFont4Color:RGB(0,0,0)];

NSMutableAttributedString*strtemp = [[NSMutableAttributedString alloc] initWithString:label1.text]; 

[strtempaddAttribute:NSForegroundColorAttributeNamevalue:RGB(153,153,153)range:NSMakeRange(strtemp.length-4,4)];

[strtemp addAttribute:NSFontAttributeNamevalue:[UIFont systemFontOfSize:14]range:NSMakeRange(strtemp.length-4,4)];

label1.attributedText= strtemp;

相关文章

网友评论

      本文标题:修改字符串中指定字符字体、颜色、大小

      本文链接:https://www.haomeiwen.com/subject/sfxstxtx.html