首页 > 移动平台 > 详细

IOS-同一label显示不同字体颜色

时间:2015-07-23 15:36:40      阅读:266      评论:0      收藏:0      [点我收藏+]

UILabel* noteLabel = [[UILabel alloc] init];
noteLabel.frame = CGRectMake(0, 100, 200, 100);
noteLabel.textColor = [UIColor blackColor];
NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:@”1111:2222”];
NSRange redRange = NSMakeRange(0, [[noteStr string] rangeOfString:@”:”].location);
[noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange];
[noteLabel setAttributedText:noteStr] ;
[noteLabel sizeToFit];
[self.view addSubview:noteLabel];

版权声明:本文为博主原创文章,未经博主允许不得转载。

IOS-同一label显示不同字体颜色

原文:http://blog.csdn.net/u010742414/article/details/47022647

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