Commit 3e37a608 authored by Steven杜宇's avatar Steven杜宇

// 方案

parent bb7dc287
...@@ -12,6 +12,8 @@ class YHImproveSchemeTemplateListCell: UITableViewCell { ...@@ -12,6 +12,8 @@ class YHImproveSchemeTemplateListCell: UITableViewCell {
static let cellReuseIdentifier = "YHImproveSchemeTemplateListCell" static let cellReuseIdentifier = "YHImproveSchemeTemplateListCell"
var model = YHSchemeTemplatesModel()
lazy var previewFileTool:YHFilePreviewTool = { lazy var previewFileTool:YHFilePreviewTool = {
let tool = YHFilePreviewTool(targetVC: UIViewController.current) let tool = YHFilePreviewTool(targetVC: UIViewController.current)
return tool return tool
...@@ -77,7 +79,7 @@ class YHImproveSchemeTemplateListCell: UITableViewCell { ...@@ -77,7 +79,7 @@ class YHImproveSchemeTemplateListCell: UITableViewCell {
make.left.equalTo(0) make.left.equalTo(0)
make.top.equalTo(16) make.top.equalTo(16)
make.bottom.equalTo(-16) make.bottom.equalTo(-16)
make.right.equalTo(rightBtn.snp.left).offset(-40) make.right.equalTo(rightBtn.snp.left).offset(-15)
} }
rightBtn.snp.makeConstraints { make in rightBtn.snp.makeConstraints { make in
......
...@@ -15,8 +15,24 @@ class YHImproveSchemeTemplateListView: UIView { ...@@ -15,8 +15,24 @@ class YHImproveSchemeTemplateListView: UIView {
return v return v
} }
let bottomFixHeight = 102.0
var items: [YHSchemeTemplatesModel] = [] { var items: [YHSchemeTemplatesModel] = [] {
didSet { didSet {
var totalHeight = bottomFixHeight+52.0
for item in items {
let height = getHeight(text: item.name)+32.0
totalHeight += height
}
totalHeight = floorl(totalHeight)
if totalHeight >= 628.0 {
totalHeight = 628.0
}
whiteView.snp.updateConstraints { make in
make.height.equalTo(totalHeight)
}
self.setNeedsLayout()
self.layoutIfNeeded()
tableView.reloadData() tableView.reloadData()
} }
} }
...@@ -138,6 +154,7 @@ extension YHImproveSchemeTemplateListView : UITableViewDelegate, UITableViewData ...@@ -138,6 +154,7 @@ extension YHImproveSchemeTemplateListView : UITableViewDelegate, UITableViewData
let item = items[indexPath.row] let item = items[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: YHImproveSchemeTemplateListCell.cellReuseIdentifier, for: indexPath) as! YHImproveSchemeTemplateListCell let cell = tableView.dequeueReusableCell(withIdentifier: YHImproveSchemeTemplateListCell.cellReuseIdentifier, for: indexPath) as! YHImproveSchemeTemplateListCell
cell.titleLabel.text = "\(indexPath.row+1)\(item.name)" cell.titleLabel.text = "\(indexPath.row+1)\(item.name)"
cell.model = item
return cell return cell
} }
...@@ -168,7 +185,14 @@ extension YHImproveSchemeTemplateListView : UITableViewDelegate, UITableViewData ...@@ -168,7 +185,14 @@ extension YHImproveSchemeTemplateListView : UITableViewDelegate, UITableViewData
} }
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.1 return bottomFixHeight
} }
func getHeight(text:String) -> CGFloat {
let size = CGSize.init(width:KScreenWidth-115 , height: CGFloat(MAXFLOAT))
let dic = [NSAttributedString.Key.font: UIFont.PFSC_R(ofSize: 14)]
let strSize = text.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context:nil).size
return CGSizeMake(strSize.width, strSize.height).height
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment