0
我跟着从这个答案here的指示,设法让我自定义的UITableView标题部分,像这样:如何添加自定义UITableView标题部分笔尖的分隔线?
override func viewDidLoad() {
super.viewDidLoad()
let nib = UINib(nibName: "TableSectionHeader", bundle: nil)
billTableView.register(nib, forHeaderFooterViewReuseIdentifier: "TableSectionHeader")
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = billTableView.dequeueReusableHeaderFooterView(withIdentifier: "TableSectionHeader")
let header = cell as! TableSectionHeader
header.lblPerson.text = array[section].name
header.lblTotal.text = "$0.00"
return cell
}
一切正常,但我需要的章节划分线,并因为部分从我的笔尖一个UIView,我不能够使用.separatorStyle
...
我需要添加分隔线,因为我想展开/折叠行。非常感谢您的帮助!
嗯,它的工作原理,但只有当我滚动了起来,向下,而不是在插入部分时。我把你的代码放在'viewForHeaderInSection'委托中。我应该在哪里插入这段代码,以便在插入节时添加分隔符? – iamhx
如果您使用xib,您可以尝试拖动UIView(seperatorView)并配置AutoLayout。 – isaced
是的,我正在使用xib。我不知道配置自动布局意味着什么..你能解释一下吗?谢谢! – iamhx