版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1338171
cell.content.numberOfLines = 3;
CGSize size = [str boundingRectWithSize:CGSizeMake([UIScreen mainScreen bounds].size.width-20, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:NSDictionary dictionaryWithObject:cell.content.font forKey:NSFontAttributeName context:nil].size;
CGRect frame = cell.content.frame;
frame.size = size;
cell.content.frame = frame;
content是cell上的一个lable.