1: UILabel
加 NSMutableAttributedString
用下面的方法计算高度.
contentSize = [dstAttrStr boundingRectWithSize:CGSizeMake(_contentLabel.frame.size.width, 100000)
options:NSStringDrawingUsesLineFragmentOrigin
context:nil].size;
2: TTTAttributedLabel
加 NSMutableAttributedString
用TTT的方法
CGSize contentSize = [TTTAttributedLabel sizeThatFitsAttributedString:dstAttrStr
withConstraints:CGSizeMake(_contentLabel.frame.size.width, 100000)
limitedToNumberOfLines:0];
时间: 2024-10-13 11:44:12