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

设置同一Label内涵不同颜色字体

时间:2016-04-23 18:18:19      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

       UILabel * label = [[UILabel alloc]init];

        NSString * htmlString = @"<span style=\"font-family:Helvetica;font-size:15pt;color:#9DC216\">感谢使用 </span> <span style=\"font-family:Helvetica;font-size:15pt;color:#222332\">Uday 友电</span>";

        NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];

        label.attributedText = attrStr;

        label.textAlignment = NSTextAlignmentCenter;

       [self.view addSubview:label];

设置同一Label内涵不同颜色字体

标签:

原文地址:http://www.cnblogs.com/zbuser/p/5425061.html

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