iOS 字符串局部改变颜色

strStaus = [晴]

NSString *str = [NSString stringWithFormat:@"天气:%@  ",,strStaus];

NSMutableAttributedString *attrDescribeStr = [[NSMutableAttributedString alloc] initWithString:str];

[attrDescribeStr addAttribute:NSForegroundColorAttributeName

value:[UIColor orangeColor]

range:[str rangeOfString:strStaus]];

self.myNameLable.attributedText = attrDescribeStr;

你可能感兴趣的:(iOS 字符串局部改变颜色)