修改UILabel的某一部分颜色需要用到NSMutableAttributedString
UILabel *label = [[UILabel alloc] init]; label.textColor = TextGrayColor; label.font = [UIFont systemFontOfSize:12];NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"网址是:https://www.baidu.com"];//更改字体 [string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:20] range:NSMakeRange(4, 21)]; //修改颜色 [string addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(4, 21)];label.attributedText = string;新闻热点
疑难解答