UITableViewController顶部奇怪的白色条带(包括图像)

时间:2017-10-20 04:40:50

标签: ios uitableview uistatusbar

UITableViewController作为UINavigationController的根。它总是出现在顶部有一个奇怪的白色条带

enter image description here

(以及状态栏始终高度的白色条带的高度)。如果我将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
    }

但之后看起来像enter image description here

其中red strip是表头,greed strip是section header。并且有一个奇怪的白色条带,滚动指示器与白色条带高度具有相同的偏移量。

1 个答案:

答案 0 :(得分:0)

唯一能帮助我的是将故事板内容插入设置为从不enter image description here