首页 > 其他 > 详细

修改UILable的属性,包括行间距等。

时间:2014-11-17 12:12:42      阅读:289      评论:0      收藏:0      [点我收藏+]

        NSDictionary* dic1 = [[NSDictionary alloc]initWithObjectsAndKeys:font,NSFontAttributeName,[@"b5b5b5" toUIColor], NSForegroundColorAttributeName,nil];

        NSDictionary* dic2 = [[NSDictionary alloc]initWithObjectsAndKeys:font,NSFontAttributeName, [@"1c66a8" toUIColor], NSForegroundColorAttributeName,nil];

        NSDictionary* dic3 = [[NSDictionary alloc]initWithObjectsAndKeys:font,NSFontAttributeName,[@"b5b5b5" toUIColor], NSForegroundColorAttributeName,nil];

        NSMutableAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString:text];

        [attrString addAttributes:dic1 range:NSMakeRange(0, 2)];

        [attrString addAttributes:dic2 range:NSMakeRange(2,commentModel.replyUser.length)];

        [attrString addAttributes:dic3 range:NSMakeRange(2+commentModel.replyUser.length,commentModel.parentInfo.content.length+1)];

        NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];

        [paragraphStyle1 setLineSpacing:8];

        [attrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [text length])];

        _replyFlagLable.attributedText = attrString;

修改UILable的属性,包括行间距等。

原文:http://www.cnblogs.com/417460188dy/p/4103173.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!