我正在尝试在自定义表格视图单元格内创建一个自定义复选框。
我有一个自定义表格视图单元格:
class CustomTableViewCell: UITableViewCell {
weak var delegate: CellDelegateT?
@IBOutlet var customCheckbox: VKCheckbox!
}
这是加载我的tableView的代码:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TransactionsTableViewCell
let customCheckbox = cell.customCheckbox!
customCheckbox.line = .thin
customCheckbox.bgColor = UIColor.white
customCheckbox.color = UIColor.black
customCheckbox.borderColor = UIColor.black
customCheckbox.borderWidth = 2
customCheckbox.cornerRadius = customCheckbox.frame.height / 2
}
我需要在哪里放置构成复选框的代码?这是cellForRowAt
不正确的地方吗?
当我在表格单元格之外使用代码时,它可以正常工作。这就是为什么我认为我将复选框创建代码放置在错误的位置。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句