文字高度问题

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];

原文地址:https://www.cnblogs.com/willbin/p/5047430.html