直接上代码
//计算多行高度
+ (CGFloat )getStringHeightWithWidth:(CGFloat)width font:(UIFont *)font string:(NSString *)string
{
NSDictionary *attribute = @{NSFontAttributeName: font};
CGSize size = [string boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
return size.height;
}