我在下面有一个桌面视图:
其中:浅灰色是tableview的。现在我想改变红色箭头指向的深灰色。浅灰色的哪个视图属于哪个?
我的表格视图有items.count
部分,每个部分有1行,如下所示:
override func numberOfSections(in tableView: UITableView) -> Int {
return items.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// build cells
}
我尝试更改cell.backgroundColor
,但它不起作用。
有什么想法吗?
此致
答案 0 :(得分:1)
Section
中的每个UITableView
的视图都是页眉/页脚。方法tableView(tableView: UITableView, viewForHeaderInSection section: Int)
将帮助您自定义
阅读this以自定义
或将 UITableView的风格 设置为plain
答案 1 :(得分:0)
您指向的箭头属于UITableView背景。
如果您想将其更改为更暗的更改
tableview.backgroundColor
答案 2 :(得分:0)
在每个单元格之间添加阴影,并根据需要从此方法中选择配置。
extension UIView {
func addShadow(){
self.clipsToBounds = true
self.layer.shadowColor = UIColor.blackColor().CGColor
self.layer.shadowOpacity = 0.1
self.layer.shadowRadius = 3.0
self.layer.shadowOffset = CGSizeMake(1.0, 1.0)
}
}
//Just like that.
cell.addShadow()
答案 3 :(得分:0)
像其他人之前所说的那样,很难分辨,因为你已经掩盖了这么多的形象。但是,如果上述答案都不起作用,请尝试更改tableview色调。并调整插图。