[英]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.