处理顶部菜单栏的tableview外观
This commit is contained in:
parent
5ebebd257a
commit
0fe9e74cec
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user