以下是我要归档的内容
我的视图层次结构很简单:我在主视图顶部有一个tableView
view.backgroundColor = .clear
tableView.backgroundColor = UIColor.clear
...
cell.backgroundColor = UIColor.clear
...
tableView.tableHeaderView = someView (with clear color)
所以,在那个设置之后,我有一个具有清晰背景颜色的tableview,如果我有一个单元格(我将其背景颜色设置为白色),那个单元格下方的空间是清晰的。但它应该是白色的。我怎么能得到它?
---已解决:
tableView.tableFooterView = UIView()
if let tableFooterView = tableView.tableFooterView {
let bigFooterView = UIView()
bigFooterView.backgroundColor = .white
tableFooterView.addSubview(bigFooterView)
bigFooterView.translatesAutoresizingMaskIntoConstraints = false
tableFooterView.addConstraint(NSLayoutConstraint(item: bigFooterView, attribute: .trailing, relatedBy: .equal, toItem: tableFooterView, attribute: .trailing, multiplier: 1, constant: 0))
tableFooterView.addConstraint(NSLayoutConstraint(item: bigFooterView, attribute: .leading, relatedBy: .equal, toItem: tableFooterView, attribute: .leading, multiplier: 1, constant: 0))
tableFooterView.addConstraint(NSLayoutConstraint(item: bigFooterView, attribute: .top, relatedBy: .equal, toItem: tableFooterView, attribute: .top, multiplier: 1, constant: 0))
tableFooterView.addConstraint(NSLayoutConstraint(item: bigFooterView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: UIScreen.main.bounds.height*2))
}
答案 0 :(得分:0)
将表格页脚设置为白色视图。
让footerView = UIView(frame:CGRect(x:0,y:0,width:0,height:someHeight)footerView.backgroundColor = .white
tableView.tableFooterView = footerView