答案 0 :(得分:1)
不太确定,我已经尝试过你的意思是什么,从你发布的代码片段中可以清楚地看出你还没有,你可以做这个 tableView 委托或在你的 headerView 本身的 awakeFromNib
中
guard let header =
detailTableView.dequeueReusableHeaderFooterView(withIdentifier: "DetailListHeaderView") as? DetailListHeaderView else { fatalError("could not create headerView") }
let backgroundView = UIView(frame: header.bounds)
backgroundView.backgroundColor = UIColor(white: 0.5, alpha: 0.5)
header.backgroundView = backgroundView
//other codes of yours
return header