1.TTTAttributedLabel里的文字高度计算和普通label的动态高度不同,如果你用普通label的动态高度计算的话,在TTTAttributedLabel里则显示不对
2.下面方法
// tttLabel是TTTAttributedLabel的实例
// _model.content是NSString实例
__block CGFloat height = 0;
[self. tttLabel setText:_model.content afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
height = [TTTAttributedLabel sizeThatFitsAttributedString:mutableAttributedString
withConstraints:CGSizeMake(200, MAXFLOAT)
limitedToNumberOfLines:0].height;
return mutableAttributedString;
}];
NSLog(@"%f",height);