From 0fe9e74cec25672db5cdff1c541d027932398ace Mon Sep 17 00:00:00 2001 From: bluesea <307723040@qq.com> Date: Tue, 30 Apr 2024 17:14:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=A1=B6=E9=83=A8=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=A0=8F=E7=9A=84tableview=E5=A4=96=E8=A7=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CCSpatialDisplayTypeView.swift | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/SwiftProject/SwiftProject/Project/View/CCSpatialDisplayTypeView/CCSpatialDisplayTypeView.swift b/SwiftProject/SwiftProject/Project/View/CCSpatialDisplayTypeView/CCSpatialDisplayTypeView.swift index 21d3a66..112daa0 100644 --- a/SwiftProject/SwiftProject/Project/View/CCSpatialDisplayTypeView/CCSpatialDisplayTypeView.swift +++ b/SwiftProject/SwiftProject/Project/View/CCSpatialDisplayTypeView/CCSpatialDisplayTypeView.swift @@ -56,7 +56,7 @@ public class CCSpatialDisplayTypeView: UIView { //菜单高度 private var popMenuItemHeight:CGFloat = 44.0 //菜单分割线颜色 - private var popMenuSplitLineColor:UIColor = UIColor(red: 222/255.0, green: 222/255.0, blue: 222/255.0, alpha: 0.5) + private var popMenuSplitLineColor:UIColor = UIColor(red: 222/255.0, green: 222/255.0, blue: 222/255.0, alpha: 0.1) //icon左间距 private var popMenuIconLeftMargin:CGFloat = 15 //菜单与屏幕边距 @@ -163,10 +163,10 @@ public class CCSpatialDisplayTypeView: UIView { popData = datas //设置myFrame size ,original会在后面计算 - myFrame = CGRect(x: 0, y: 0, width: menuWidth, height: popMenuItemHeight*CGFloat(popData.count)) - myFrame.size.height = min(KScrH/2, myFrame.height) - myFrame.size.width = min(KScrW-popMenuMargin*2, myFrame.width) - +// myFrame = CGRect(x: 0, y: 0, width: menuWidth, height: popMenuItemHeight*CGFloat(popData.count)) +// myFrame.size.height = min(KScrH/2, myFrame.height) +// myFrame.size.width = min(KScrW-popMenuMargin*2, myFrame.width) + updateMyFrameHeight(menuWidth: menuWidth) //设置肩头,与屏幕间隔10 arrowPoint = arrow arrowPoint.x = max(popMenuMargin, min(arrowPoint.x, KScrW-popMenuMargin)) @@ -184,11 +184,23 @@ public class CCSpatialDisplayTypeView: UIView { //MARK: - 设置数据源 func setData(datas:[(icon:String,title:String,isHiden:Bool)]) { popData = datas + if tableView != nil { + updateMyFrameHeight(menuWidth: tableView.width) + } + if(isShowing){ tableView.reloadData() } } + //MARK: - 更新myframe高度 + func updateMyFrameHeight(menuWidth:CGFloat) { + //设置myFrame size ,original会在后面计算 + myFrame = CGRect(x: 0, y: 0, width: menuWidth, height: popMenuItemHeight*CGFloat(popData.count)) + myFrame.size.height = min(KScrH/2, myFrame.height) + myFrame.size.width = min(KScrW-popMenuMargin*2, myFrame.width) + } + //MARK: - 设置是否展示Footer func showFooterView(isShow:Bool,showText:String) { @@ -244,6 +256,8 @@ public class CCSpatialDisplayTypeView: UIView { tableView.delegate = self tableView.dataSource = self tableView.bounces = false + tableView.showsVerticalScrollIndicator = false + tableView.isScrollEnabled = false UIView.animate(withDuration: 0.3) {[weak self] in self?.addSubview((self?.tableView)!) } @@ -424,7 +438,7 @@ class CCSpatialDisplayTypeCell: UITableViewCell { var line:UIView! //自定义属性 - var lineColor:UIColor = UIColor(red: 222/255.0, green: 222/255.0, blue: 222/255.0, alpha: 0.5) + var lineColor:UIColor = UIColor(red: 222/255.0, green: 222/255.0, blue: 222/255.0, alpha: 0.1) var txtColor:UIColor = UIColor.black var txtFont:UIFont = KFont_Medium(12) var iconLeft:CGFloat = 15 @@ -494,7 +508,7 @@ class CCSpatialDisplayTypeCell: UITableViewCell { //有图片 self.lblTitle.textAlignment = .left self.lblTitle.frame = CGRect(x: 16, y: 0, width: self.frame.size.width - 42, height: self.frame.size.height) - self.line.frame = CGRect(x: 0, y: self.frame.size.height - 1, width: self.frame.size.width, height: 1) + self.line.frame = CGRect(x: 0, y: self.frame.size.height - 1, width: self.frame.size.width, height: 0.5) self.arrowImage.frame = CGRect(x: self.bounds.size.width - 26, y: (self.bounds.size.height - 12)/2, width: 12, height: 12) @@ -502,7 +516,7 @@ class CCSpatialDisplayTypeCell: UITableViewCell { //无图片 self.lblTitle.textAlignment = .center self.lblTitle.frame = CGRect(x: 16, y: 0, width: self.frame.size.width - 32, height: self.frame.size.height) - self.line.frame = CGRect(x: 0, y: self.frame.size.height - 1, width: self.frame.size.width, height: 1) + self.line.frame = CGRect(x: 0, y: self.frame.size.height - 1, width: self.frame.size.width, height: 0.5) } }