【发布时间】:2019-11-26 16:00:06
【问题描述】:
我的UITableView 有问题。最终我希望它看起来像这样(白色矩形)。
如何设置.backgroundcolor 使其清晰,如图所示??
我遇到的另一个问题是我的TableView 被“预填充”为空的cells..
我已经尝试过了,但不知何故它不起作用:
TableViewController类
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: WhishCell.reuseID, for: indexPath)
let currentWish = self.wishList[indexPath.row]
cell.textLabel?.text = currentWish.wishName
cell.backgroundColor = .clear
return cell
}
自定义Cell类
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.addSubview(checkButton)
self.backgroundColor = .clear
}
我如何创建我的UITableView
let theTableView: WhishlistTableViewController = {
let v = WhishlistTableViewController()
v.view.layer.masksToBounds = true
v.view.layer.borderColor = UIColor.white.cgColor
v.view.backgroundColor = .clear
v.view.layer.borderWidth = 2.0
v.view.translatesAutoresizingMaskIntoConstraints = false
return v
}()
我的UITableView 的所有功能都运行良好。只是backgroundcolor 和空的cells...
感谢您的帮助 :) 我在这方面找不到任何东西..
【问题讨论】:
标签: ios swift uitableview tableview