记录一下
- (CGFloat)calculateHeight:(NSString *)string Width:(CGFloat)width fontSize:(CGFloat)fontSize {
CGSize size = CGSizeMake(width, MAXFLOAT);
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setLineSpacing:10];
NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:fontSize], NSParagraphStyleAttributeName:style};
CGFloat height = [string boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:dic context:nil].size.height;
return height;
}
网友评论