【问题标题】:How can I fill the top of view with my tableView?如何用我的 tableView 填充视图顶部?
【发布时间】:2018-11-16 15:53:56
【问题描述】:

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

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

像这样

但现在看起来像这样。

谢谢。

【问题讨论】:

  • 我的导航栏已经是透明的了。但是第一个单元格的默认位置不是我想要的......即使我将tableView的约束设置为superView,它总是在导航栏的底部。
  • 我不确定,但您可以尝试将tableView 中的contentInset 设置到屏幕顶部

标签: swift uitableview uinavigationcontroller uinavigationbar


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

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

【讨论】:

  • 请接受您自己的答案,以便不再将问题列为未回答。
猜你喜欢
  • 2015-08-15
  • 1970-01-01
  • 1970-01-01
  • 2012-11-26
  • 2022-12-03
  • 2014-04-13
  • 1970-01-01
  • 2022-11-08
  • 2022-01-14
相关资源
最近更新 更多