标签:
UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 300)]; lable.text = @"其中俩字是红色,大小为17"; NSRange rangeRmb=[lable.text rangeOfString:[NSString stringWithFormat:@"红色"]]; NSMutableAttributedString *rmbStr=[[NSMutableAttributedString alloc] initWithString:lable.text attributes:nil]; if ([[[UIDevice currentDevice] systemVersion] floatValue]>=6.0) { NSDictionary *fontDic=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName,[UIFont systemFontOfSize:17],NSFontAttributeName, nil]; [rmbStr addAttributes:fontDic range:rangeRmb]; lable.attributedText = rmbStr; }else{ lable.text=rmbStr.string; }
标签:
原文地址:http://www.cnblogs.com/mlgbya/p/4287451.html