首页 > 其他 > 详细

UIlabel设置不同的颜色

时间:2015-08-28 00:34:18      阅读:235      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!