根据文本 + 字体 + 给定宽度, 计算高度
+ (CGFloat)getHeightForText:(NSString *)textShow
font:(UIFont *)fontShow
width:(CGFloat)widthShow
{
return [textShow boundingRectWithSize:CGSizeMake(widthShow, 10000000) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:fontShow} context:nil].size.height;
}```
根据图片 + 宽度, 计算等比例的高度
-
(CGFloat)getHeightForImage:(NSString *)iamgeName
width:(CGFloat)widthShow
{return widthShow / [UIImage imageNamed:iamgeName].size.width * [UIImage imageNamed:iamgeName].size.height;
}```