Commit 83270873 authored by Steven杜宇's avatar Steven杜宇

// 方案

parent 789d2e49
......@@ -11,7 +11,12 @@ import UIKit
class YHPlanViewController: YHBaseViewController {
var infoArr: [String] = ["", "", "", ""]
var cases: [String] = ["水电费噶事多发结石冷风机拉萨反垃圾算法逻辑的山卡拉飞机啊索拉卡飞机啊拉卡萨",
"阿斯顿发发", "阿斯顿发生大法师懂法守法说法大萨达法司法发沙发是打发三大发实达防擦是打发",
"啊所发生的发生的放假啦苏卡达飞机拉萨开发机阿萨拉法基阿萨拉开发",
"双法防",
"沙发上",
"啊防守打法"]
lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
......@@ -33,12 +38,21 @@ class YHPlanViewController: YHBaseViewController {
return tableView
}()
let v = YHPlanScoreChart(frame: .zero)
lazy var bgImgView: UIImageView = {
let v = UIImageView()
v.image = UIImage(named: "plan_list_head_bg")
return v
}()
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .black
self.view.backgroundColor = .init(hex: 0xF5F6F8)
self.view.addSubview(bgImgView)
self.view.addSubview(tableView)
bgImgView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(bgImgView.snp.width)
}
tableView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.top.equalTo(200)
......@@ -75,12 +89,7 @@ extension YHPlanViewController: UITableViewDelegate, UITableViewDataSource {
guard let cell3 = tableView.dequeueReusableCell(withIdentifier: YHPlanCustomerCaseListCell.cellReuseIdentifier, for: indexPath) as? YHPlanCustomerCaseListCell else {
return UITableViewCell()
}
cell3.cases = ["水电费噶事多发结石冷风机拉萨反垃圾算法逻辑的山卡拉飞机啊索拉卡飞机啊拉卡萨",
"阿斯顿发发", "阿斯顿发生大法师懂法守法说法大萨达法司法发沙发是打发三大发实达防擦是打发",
"啊所发生的发生的放假啦苏卡达飞机拉萨开发机阿萨拉法基阿萨拉开发",
"双法防",
"沙发上",
"啊防守打法"]
cell3.cases = self.cases
return cell3
}
}
......@@ -89,8 +98,9 @@ extension YHPlanViewController: UITableViewDelegate, UITableViewDataSource {
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 3 {
return 2000
return getCaseListHeight()
}
return UITableView.automaticDimension
}
......@@ -111,5 +121,33 @@ extension YHPlanViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 1.0
}
// 计算文字宽度大小
func getHeigt(font: UIFont, width: CGFloat, string: String) -> CGFloat {
let size = CGSize.init(width: width, height: CGFloat(MAXFLOAT))
let dic = [NSAttributedString.Key.font: font] // swift 4.2
let strSize = string.boundingRect(with: size, options: [.usesLineFragmentOrigin], attributes: dic, context: nil).size
return ceil(strSize.height)
}
func getCaseListHeight() -> CGFloat {
let cellWidth = floor((KScreenWidth-16.0*2.0-10.0)/2.0)
var yOffset1 = 0.0
var yOffset2 = 0.0
for (index, item) in cases.enumerated() {
var textHeight = self.getHeigt(font: UIFont.PFSC_R(ofSize: 14), width: cellWidth-8.0*2.0, string: cases[index])
let caseCellHeight = textHeight + (cellWidth*(200.0/166.0) + 8.0+12.0+10.0)
if index % 2 == 0 {
yOffset1 += caseCellHeight
} else {
yOffset2 += caseCellHeight
}
}
let contentHeight = max(yOffset1, yOffset2) + 20.0 + 12.0
return contentHeight
}
}
......@@ -52,7 +52,8 @@ class YHPlanCustomerCaseCollectionCell: UICollectionViewCell {
whiteContentView.addSubview(descLabel)
whiteContentView.snp.makeConstraints { make in
make.edges.equalToSuperview()
make.top.left.right.equalToSuperview()
make.bottom.equalTo(-10)
}
iconImgV.snp.makeConstraints { make in
......@@ -63,8 +64,8 @@ class YHPlanCustomerCaseCollectionCell: UICollectionViewCell {
descLabel.snp.makeConstraints { make in
make.top.equalTo(iconImgV.snp.bottom).offset(8)
make.bottom.equalTo(-12)
make.left.equalTo(12)
make.right.equalTo(-12)
make.left.equalTo(8)
make.right.equalTo(-8)
}
}
}
......@@ -34,6 +34,7 @@ class YHPlanCustomerCaseListCell: UITableViewCell {
collectView.delegate = self
collectView.dataSource = self
collectView.register(YHPlanCustomerCaseCollectionCell.self, forCellWithReuseIdentifier: YHPlanCustomerCaseCollectionCell.cellReuseIdentifier)
collectView.isScrollEnabled = false
return collectView
}()
......@@ -103,9 +104,9 @@ extension YHPlanCustomerCaseListCell: UICollectionViewDelegate, UICollectionView
// 返回每个单元格的大小
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let cellWidth = floor(KScreenWidth-16.0*2.0-10.0)/2.0
var height = self.getHeigt(font: UIFont.PFSC_R(ofSize: 14), width: cellWidth, string: cases[indexPath.item])
height += (cellWidth*(200.0/166.0) + 20.0)
let cellWidth = floor((KScreenWidth-16.0*2.0-10.0)/2.0)
var height = self.getHeigt(font: UIFont.PFSC_R(ofSize: 14), width: cellWidth-8.0*2.0, string: cases[indexPath.item])
height += (cellWidth*(200.0/166.0) + 8.0+12.0+10.0)
return CGSize(width: cellWidth, height: height)
}
......
......@@ -11,7 +11,7 @@ import UIKit
class YHPlanCustomerCaseListLayout: UICollectionViewLayout {
// MARK: - 配置属性
let cellWidth = floor(KScreenWidth-16.0*2.0-10.0)/2.0
let cellWidth = floor((KScreenWidth-16.0*2.0-10.0)/2.0)
let cellPadding = 10.0
let cellGap = 10.0
private var contentHeight: CGFloat = 0
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "BG@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "BG@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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