不同颜色文字拼接显示

NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"距离开课还有%@天",[NSString stringWithFormat:@"%@",[[response objectForKey:@"message"] objectForKey:@"days"]]]];
                            
[str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1] range:NSMakeRange(6,[[NSString stringWithFormat:@"%@",[[response objectForKey:@"message"] objectForKey:@"days"]] length])];
                            
_dayCount.attributedText = str;

猜你喜欢

转载自blog.csdn.net/YY_Seven/article/details/50370150