gpt4 book ai didi

ios - 如何在状态栏后面获取 uitableview 标题?

转载 作者:行者123 更新时间:2023-12-01 19:54:17 25 4
gpt4 key购买 nike

我添加了两张图片,第一张显示我想要的,第二张显示正在发生的事情。我希望 uitableview 标题位于状态栏后面,如第一张图片所示。部署目标是 9.2

enter image description here

第二个是

enter image description here

最佳答案

我假设您正在使用 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
)
)

这是它在我的模拟器中的外观:

enter image description here

要让表格标题在状态栏下方开始,只需使用 layoutGuide.bottom属性而不是 .top :

enter image description here

在这里可以 download测试项目。

关于ios - 如何在状态栏后面获取 uitableview 标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43611310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com