IOS-同一label显示不同字体颜色

UILabel* noteLabel = [[UILabel alloc] init]; noteLabel.frame = CGRectMake(0, 100, 200, 100); noteLabel.textColor = [UIColor blackColor]; NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:@”1111:2222”]; NSRange redRange = NSMakeRange(0, [[noteStr string] rangeOfString:@”:”].location); [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange]; [noteLabel setAttributedText:noteStr] ; [noteLabel sizeToFit]; [self.view addSubview:noteLabel];

版权声明:本文为博主原创文章,未经博主允许不得转载。

,在时间里面我们什么也不能留下,包括痛苦,快乐和生命。

IOS-同一label显示不同字体颜色

相关文章:

你感兴趣的文章:

标签云: