Lable 富文本代码

 //4.设置Label上的文字
    AnswerModel *model = [self getFitModel:tableView];
    
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"答案解析:%@",model.bestanswer]];
    [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, 5)];
    [AttributedStr addAttribute:NSForegroundColorAttributeName  value:[UIColor colorWithRed:10/255.0 green:145/255.0 blue:229/255.0 alpha:1.0]range:NSMakeRange(0, 5)];
    label.attributedText = AttributedStr;

你可能感兴趣的:(iOS)