如何用我的 tableView 填充视图的顶部?

How can I fill the top of view with my tableView?

我的视图中有一个透明的导航栏和一个 tableView。

我想要做的是用我的第一个单元格填充导航栏和状态栏的所有部分并删除上边距。

像这样

但现在是这个样子

谢谢。

let yOffset = UIApplication.shared.statusBarFrame.height + self.navigationController!.navigationBar.frame.size.height
tableView.contentInset = UIEdgeInsets(top: -yOffset, left: 0, bottom: 0, right: 0)

这解决了我的问题。谢谢大家!