[ios]自定义cell作为section header

1.在storyboard中放置一个 table view cell,设置好identifier和content view的tag。
2.实现 tableView:viewForHeaderInSection 方法:

1
2
3
4
5
6
7
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

let cellIdentifier = "sectionHeader0"
let headerView = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)?.viewWithTag(101)
return headerView

}

3.实现 tableView:heightForHeaderInSection 方法