我UITableViewController
作为UINavigationController
的根。它总是出现在顶部有一个奇怪的白色条带
(以及状态栏始终高度的白色条带的高度)。如果我将tableView的背景颜色更改为红色,则条带变为红色,这意味着问题出现在UITableViewController
我认为可能是问题是因为表视图标题或节标题,所以我添加了这个代码来检查
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 10
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView()
view.backgroundColor = UIColor.green
return view
}
func configureTabeView() {
// self.tableView.contentInset = UIEdgeInsets(top: -1, left: 0, bottom: 0, right: 0)
let viewHeader = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 1))
viewHeader.backgroundColor = UIColor.red
self.tableView.tableHeaderView = viewHeader
tableView.clipsToBounds = true
}
其中red strip是表头,greed strip是section header。并且有一个奇怪的白色条带,滚动指示器与白色条带高度具有相同的偏移量。