//自动计算text的高度
+ (CGFloat)calculateStrHeightWithString:(NSString *)string
font:(float)fontSize
viewWidth:(CGFloat)viewWidth
{
string = [self removeWhitespaceAndNewWithString:string];
CGSize size = [string boundingRectWithSize:CGSizeMake(viewWidth, MAXFLOAT) options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]} context:nil].size;
return ceil(size.height);
}
+ (NSString *)removeWhitespaceAndNewWithString:(NSString *)string
{
NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
return [string stringByTrimmingCharactersInSet:set];
}