我添加了使用安全区域指南的选项但是当我查看应用程序时,它似乎尊重安全区域,但是我无法摆脱一些空白区域。我不知道是什么导致它,我也不知道如何改变白色的颜色。
我已将背景颜色设置为您在下面看到的颜色。
view.backgroundColor = UIColor(red:0.227, green:0.251, blue:0.294, alpha:1)
我还设置了白色状态栏样式
UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
我的主要故事板
答案 0 :(得分:2)
当视图在屏幕上可见时,本指南反映了该部分 导航栏,标签栏,工具栏未覆盖的视图, 和其他祖先的观点。 (在tvOS中,安全区域反映了该区域 没有覆盖屏幕的挡板。)如果视图当前不是 安装在视图层次结构中,或者在屏幕上尚未显示, 布局引导边等于视图的边缘。
您需要使用safeArea设置约束
使用webView
设置safeArea
的顶部,底部,前导,尾随约束
常数为0,因此您的对象不会剪辑。
以编程方式:
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
}
答案 1 :(得分:0)
if #available(iOS 11.0, *) {
webView.scrollView.contentInsetAdjustmentBehavior = .never;
}