最佳答案
我假设您正在使用 Autolayout
所以你可以约束 tableView 的 .top
其 super View 的 .top
的边距或查看 Controller 的 topLayoutGuide
属性,以便表格 View 将从 0
开始:
let toItem: Any = self.topLayoutGuide
// You can change this to `self.view` to have the same effect.
view.addConstraint(
NSLayoutConstraint(item: tableView,
attribute: NSLayoutAttribute.top,
relatedBy: NSLayoutRelation.equal,
toItem: toItem,
attribute: NSLayoutAttribute.top,
multiplier: 1.0, constant: 0
)
)
这是它在我的模拟器中的外观:
要让表格标题在状态栏下方开始,只需使用
layoutGuide
的.bottom
属性而不是 .top
:在这里可以download测试项目。
关于ios - 如何在状态栏后面获取 uitableview 标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43611310/