UILabel高度自适应

1.self.detailTextLabel.numberOfLines = 0;

2.CGRect rectToFit = [text boundingRectWithSize:CGSizeMake(240.0f, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0f]} context:nil];

text是UILabel的文本

3.自适应的高度是rectToFit.size.height

推荐阅读更多精彩内容