[英]How do I create a tableview cell like this programmatically?
如何创建一个像以红色突出显示的单元格一样的表格视图单元格? 我需要以编程方式创建它。 我目前正在使用 Eureka 和 ViewRow 库。
+++ Section("ViewRow Demo")
<<< ViewRow<MyView>("view") { (row) in
row.title = "My View Title" // optional
}
.cellSetup { (cell, row) in
// Construct the view for the cell
cell.view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 200))
}
要覆盖选择上的突出显示单元格,我使用 selectionBackground 类
class SelectionView: UIView {
public override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor.YOUR_PREFERED_COLOR.withAlphaComponent(0.3)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
fatalError("init(coder:) has not been implemented")
}
}
用法: cell.selectedBackgroundView = SelectionView(frame: cell.frame)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.