- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
_removeHeight = [SystermTableViewCell setHeightForRow:_model.data[indexPath.section][@"description"]];
return _removeHeight;
}
+(CGFloat)setHeightForRow:(NSString *)str{
CGFloat textHeight = [[DataManager shareDataManager] getHeightOfText:str fontOfText:[UIFont systemFontOfSize:14*ratew] widthOfText:kScreenW-20];
CGFloat rowHeight =textHeight+32+45;
return rowHeight;
}
//得到文本高度
-(CGFloat)getHeightOfText:(NSString *)text fontOfText:(UIFont *)font widthOfText:(CGFloat)width{
CGRect rect = [text boundingRectWithSize:CGSizeMake(width, MAX_CANON) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} context:nil];
return rect.size.height>21.0 ? rect.size.height : 21.0;
}
网友评论