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

UIlabel设置不同的颜色

时间:2015-08-28 00:35:04      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

NSString *string = @"注册过程中出现问题,致电400-650-5167联系会养车工作人员";
    NSRange range = [string rangeOfString: @"400-650-5167"];
    NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString: string];
    [attribute addAttributes: @{NSForegroundColorAttributeName: [UIColor colorWithRed:84.0f/255.0f green:116.0f/255.0f blue:173.0f/255.0f alpha:1.0f]} range: range];
UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(0, 200, 320.0, 100.0)];
    [label setText: string];
    label.textColor = [UIColor colorWithRed:102.0f/255.0f green:102.0f/255.0f blue:102.0f/255.0f alpha:1.0f];
    label.font = [UIFont boldSystemFontOfSize:14];
    label.numberOfLines = 0;
    [label setAttributedText: attribute];
    [self.view addSubview:label]; 

UIlabel设置不同的颜色

标签:

原文地址:http://www.cnblogs.com/wskgjmhh/p/4764883.html

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