gpt4 book ai didi

ios - 如何设置状态栏或安全区域以去除 iPhone X 上的空白?

转载 作者:搜寻专家 更新时间:2023-10-31 22:40:51 25 4
gpt4 key购买 nike

我已经添加了使用安全区域准则的选项,但当我查看该应用程序时,它似乎尊重安全区域,但有一些我无法摆脱的空白。我不知道是什么原因造成的,也不知道如何将颜色从白色更改。

我已将背景颜色设置为您在下面看到的颜色。

view.backgroundColor = UIColor(red:0.227, green:0.251, blue:0.294, alpha:1)

我还设置了白色状态栏样式

UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent

enter image description here

我的主要 Storyboard

enter image description here

enter image description here enter image description here

最佳答案

When the view is visible onscreen, this guide reflects the portion of the view that is not covered by navigation bars, tab bars, toolbars, and other ancestor views. (In tvOS, the safe area reflects the area not covered the screen's bezel.) If the view is not currently installed in a view hierarchy, or is not yet visible onscreen, the layout guide edges are equal to the edges of the view.

需要用safeArea设置约束使用 safeArea 设置 webView 的顶部、底部、前导、尾随约束常量为 0,因此您的对象不会裁剪。 enter image description here

以编程方式作为:

 webView.translatesAutoresizingMaskIntoConstraints = false
if #available(iOS 11.0, *) {
let guide = self.view.safeAreaLayoutGuide
webView.trailingAnchor.constraint(equalTo: guide.trailingAnchor).isActive = true
webView.leadingAnchor.constraint(equalTo: guide.leadingAnchor).isActive = true
webView.bottomAnchor.constraint(equalTo: guide.bottomAnchor).isActive = true
webView.topAnchor.constraint(equalTo: guide.topAnchor).isActive = true
}

SafeAreaGuide

关于ios - 如何设置状态栏或安全区域以去除 iPhone X 上的空白?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47144589/

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