我正在使用 TTTAttributedLabel,我通常在我的 tableview 单元格中使用 sizetofit。之后,我在单元格高度计算中使用 sizeWithFont。我这样设置 TTTAttributedLabel 。
[self.attributedLabel setText:@"Test\n\n\n\n"];
CGSize contentSize = [self.attributedLabel.text sizeWithFont:self.attributedLabel.font
constrainedToSize:CGSizeMake(CGRectGetWidth(self.attributedLabel.frame), 1000)
lineBreakMode:NSLineBreakByWordWrapping];
[self.attributedLabel sizeToFit];
我注意到高度不同。我得到了这样的输出。所以我猜是错的。我可以知道如何解决吗?我正在 iOS 8 设备上进行测试。