【问题标题】:How to include statusbar space in UITableViewController如何在 UITableViewController 中包含状态栏空间
【发布时间】:2019-08-19 19:53:49
【问题描述】:

我正在使用 UITableview 控制器,并为 tableView 的背景设置图像。

如何在不隐藏状态栏的情况下将顶部空白 (Stausbar) 包含到视图中。

【问题讨论】:

  • 您是否尝试删除其背景颜色? tableView.backgroundColor = UIColor.clear
  • 我不想去掉大的颜色。我想将屏幕扩展到顶部。
  • @VineeshTP 你看到我的回答有用吗?

标签: swift uitableview statusbar


【解决方案1】:

通过从SafeArea.top to superview.top更改顶部约束来解决

【讨论】:

    【解决方案2】:

    您必须设置 contentInset 顶部状态栏高度。

    let statusBarHeight:CGFloat = UIApplication.shared.statusBarFrame.size.height
    tableView.contentInset = UIEdgeInsets(top: -statusBarHeight, left: 0, bottom: 0, right: 0)
    

    如果您使用 StoryBoard 设置最高值:-20

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-23
      • 1970-01-01
      • 2013-12-07
      • 2021-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多