UITableView grouped之调整任意header、footer首尾高度
来源:互联网 发布:centoa安装java 7u80 编辑:程序博客网 时间:2024/05/17 22:03
实现思路:用.plain格式的tableView,自定义分割高度,避开了一头雾水的 .grouped
class ELTableControllerGrouped: UIViewController, UITableViewDataSource, UITableViewDelegate { var table: UITableView! var sectionCount = 5 var heightForFooter: CGFloat = 18 var heightForHeader: CGFloat = 0 override func viewDidLoad() { super.viewDidLoad() table = UITableView(frame: view.bounds, style: .plain) table.delegate = self table.dataSource = self table.register(UITableViewCell.self, forCellReuseIdentifier: "c") table.register(UITableViewHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: "v") view.addSubview(table) table.backgroundColor = UIColor.groupTableViewBackground } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "c") cell?.textLabel?.text = "dcas" return cell! } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return section == sectionCount-1 ? 0 : heightForFooter } func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { let v1 = tableView.dequeueReusableHeaderFooterView(withIdentifier: "v")! v1.contentView.backgroundColor = UIColor.groupTableViewBackground return section == sectionCount-1 ? nil : v1 } func numberOfSections(in tableView: UITableView) -> Int { return sectionCount } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 4 }}
阅读全文
0 0
- UITableView grouped之调整任意header、footer首尾高度
- UITableView类型为grouped时,如何设置footer的高度为0
- 去掉UItableview header(footer)view 黏性(sticky)
- 去掉UItableview header(footer)view黏性(sticky)
- 去掉UItableview header(footer)view黏性(sticky)
- 去掉UItableview header(footer)view黏性
- UITableView中Header和Footer悬停方式
- 自定义UITableView的Header和Footer
- UITableView去掉Grouped样式的第一组Header组头
- iOS开发之UITableView自定义Header视图和自定义Footer视图
- UITableView自动调整Cell高度
- 如何去掉UITableView中的header和footer的粘连效果
- 去掉UITableView的header和footer的黏性效果
- 如何去掉UItableview header(footer)view黏性(sticky)?
- iOS 去掉UItableview header(footer)view黏性(sticky)?
- 用 xib / Storyboard 创建 UITableView 的 header 和 footer
- Header Footer
- UICollectionView Header footer 从xib加载动态高度
- 大数据预科班总结
- 求取a-b中约数最大数字的约数
- Eslipse辅助键
- tcl库、包、模块的创建与使用
- MySQL
- UITableView grouped之调整任意header、footer首尾高度
- Java常用类 集合框架
- 什么是实时操作系统和非实时操作系统?
- edgeR的使用
- Java语言基础
- SpringBoot和Swagger结合提高API开发效率
- 计算机小白突破自己的第一步
- esxi gui
- bzoj2318Spoj4060 game with probability Problem 期望DP