我目前正在使用 UICollectionReusableView 为表格 View 制作自定义 header 。我面临的问题是这个标题没有像我想要的那样随表格 View 滚动。这是我实现 headerview 的方法:
func numberOfSections(in tableView: UITableView) -> Int {
return 1;
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = Bundle.main.loadNibNamed("StoresListHeaderView", owner: self, options: nil)?.first as! StoresListHeaderView;
return headerView;
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 170;
}
在 UICollectionReusableView .swift 文件中,有默认代码,在 .xib 中只有一个背景图像。
是否有任何 bool 选项可以进行设置?否则你会用什么?
最佳答案
如果不是,请尝试将 UITableView 的 style
属性更改为 .plain
。 .grouped
样式将在滚动时将标题保留在屏幕上。
关于ios - 使用 UICollectionReusableView 的 UITableView 自定义 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50417975/