[英]How to set Section Border In tableview With Expanding and Collapsing?
我正在創建一個設計。 在此設計中,我必須為具有折疊和展開功能的部分設置邊框顏色。 我為自定義部分創建了一個 Xib 文件,但它只在部分中顯示邊框顏色。 我想要整個部分的顏色。 不管里面有多少行。 和我的第一部分僅擴展...如果單擊其他部分則不會擴展。 o 部分是展開的。
struct Section {
var name: String!
var items: [String]!
var collapsed: Bool!
init(name: String, items: [String]) {
self.name = name
self.items = items
self.collapsed = true
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection
section: Int) -> Int {
if tableView == self.preparingTableView {
return 2
} else {
return (sections[section].collapsed!) ? 0 : 4
}
}
這是用於檢查切換按鈕的 function
@objc func toggleCollapse(sender: UIButton) {
let section = sender.tag
let collapsed = sections[section].collapsed
sections[section].collapsed = !collapsed!
// Reload section
self.wareHouseTable.reloadSections(NSIndexSet(index: section)
as IndexSet, with: .automatic)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.