iOS TableHeaderView、TableFooterView 自动高度 UIView 中的设置 import UIKit class MultiLineLabelHeaderFooterView: UIView { @IBOutlet weak var contentLabel: UILabel! /* // Only override draw() if you perform custom drawing. // An empty implementation adversely affects performance during animation. override func draw(_ rect: CGRect)
iOS 去掉 UITableView 顶部的多余空间 将 UITableView 的 style 设为 grouped 后发现顶部出现了大约有35px的额外空白。 原因是 group 样式的 UITableView 顶部会生成自带初始高度的 tableHeaderView。解决方案将 tableHeaderView 替换成一个高度为0的 UIView。首先尝试将高度设为 CGRectZero: // 这种写法有问题 UIView *tableViewHeaderView = [[UIView alloc] initWithFrame:CGRectZero]; self.tableView.tableHeaderView = tableViewHeaderView; 另外,如果 UITableView