处理顶部菜单栏的tableview外观

This commit is contained in:
bluesea 2024-04-30 17:14:18 +08:00
parent 5ebebd257a
commit 0fe9e74cec

View File

@ -56,7 +56,7 @@ public class CCSpatialDisplayTypeView: UIView {
// //
private var popMenuItemHeight:CGFloat = 44.0 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 //icon
private var popMenuIconLeftMargin:CGFloat = 15 private var popMenuIconLeftMargin:CGFloat = 15
// //
@ -163,10 +163,10 @@ public class CCSpatialDisplayTypeView: UIView {
popData = datas popData = datas
//myFrame size ,original //myFrame size ,original
myFrame = CGRect(x: 0, y: 0, width: menuWidth, height: popMenuItemHeight*CGFloat(popData.count)) // myFrame = CGRect(x: 0, y: 0, width: menuWidth, height: popMenuItemHeight*CGFloat(popData.count))
myFrame.size.height = min(KScrH/2, myFrame.height) // myFrame.size.height = min(KScrH/2, myFrame.height)
myFrame.size.width = min(KScrW-popMenuMargin*2, myFrame.width) // myFrame.size.width = min(KScrW-popMenuMargin*2, myFrame.width)
updateMyFrameHeight(menuWidth: menuWidth)
//10 //10
arrowPoint = arrow arrowPoint = arrow
arrowPoint.x = max(popMenuMargin, min(arrowPoint.x, KScrW-popMenuMargin)) arrowPoint.x = max(popMenuMargin, min(arrowPoint.x, KScrW-popMenuMargin))
@ -184,11 +184,23 @@ public class CCSpatialDisplayTypeView: UIView {
//MARK: - //MARK: -
func setData(datas:[(icon:String,title:String,isHiden:Bool)]) { func setData(datas:[(icon:String,title:String,isHiden:Bool)]) {
popData = datas popData = datas
if tableView != nil {
updateMyFrameHeight(menuWidth: tableView.width)
}
if(isShowing){ if(isShowing){
tableView.reloadData() 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 //MARK: - Footer
func showFooterView(isShow:Bool,showText:String) { func showFooterView(isShow:Bool,showText:String) {
@ -244,6 +256,8 @@ public class CCSpatialDisplayTypeView: UIView {
tableView.delegate = self tableView.delegate = self
tableView.dataSource = self tableView.dataSource = self
tableView.bounces = false tableView.bounces = false
tableView.showsVerticalScrollIndicator = false
tableView.isScrollEnabled = false
UIView.animate(withDuration: 0.3) {[weak self] in UIView.animate(withDuration: 0.3) {[weak self] in
self?.addSubview((self?.tableView)!) self?.addSubview((self?.tableView)!)
} }
@ -424,7 +438,7 @@ class CCSpatialDisplayTypeCell: UITableViewCell {
var line:UIView! 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 txtColor:UIColor = UIColor.black
var txtFont:UIFont = KFont_Medium(12) var txtFont:UIFont = KFont_Medium(12)
var iconLeft:CGFloat = 15 var iconLeft:CGFloat = 15
@ -494,7 +508,7 @@ class CCSpatialDisplayTypeCell: UITableViewCell {
// //
self.lblTitle.textAlignment = .left self.lblTitle.textAlignment = .left
self.lblTitle.frame = CGRect(x: 16, y: 0, width: self.frame.size.width - 42, height: self.frame.size.height) 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) 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.textAlignment = .center
self.lblTitle.frame = CGRect(x: 16, y: 0, width: self.frame.size.width - 32, height: self.frame.size.height) 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)
} }
} }