navigationBar 和 tableview 单元格之间的间距

Spacing between navigationBar and tableview cell

如何在 navigationBar 和第一个 UITableViewCell 之间添加间距?

您需要将 contentInset 添加到您的 UITableView 第一个值用于 top inset 第二个值用于 left 第三个用于bottom 最后一个 right

像这样

self.tableView.contentInset = UIEdgeInsetsMake(10, 0, 0, 0) //replace 10 by your needed value

您不需要从单元格中执行此操作,而是从表视图中执行: 转到您的 tableview 所在的故事板,并将 tableview 的顶部约束更改为大于当前的 0。