美文网首页
富文本改变颜色字体

富文本改变颜色字体

作者: ljzza | 来源:发表于2017-12-01 14:44 被阅读0次
            NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@回复%@: %@",model.userName,model.name,model.content]];
            [AttributedStr addAttribute:NSForegroundColorAttributeName value:colorWithMainColor range:NSMakeRange(0, model.userName.length)];
            [AttributedStr addAttribute:NSForegroundColorAttributeName value:colorWithMainColor range:NSMakeRange(model.userName.length + @"回复".length,model.name.length)];
            _titleLabel.attributedText = AttributedStr;
           ([AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0]   range:NSMakeRange(0, 5)];)
    

    相关文章

      网友评论

          本文标题:富文本改变颜色字体

          本文链接:https://www.haomeiwen.com/subject/nncwbxtx.html