gpt4 book ai didi

ios - 如何将 View 高度调整到 iOS 中的导航栏下方?

转载 作者:行者123 更新时间:2023-11-28 05:53:38 30 4
gpt4 key购买 nike

我在代码中创建了一个 WKWebView 并将其添加到我的 View 中。

override func loadView() {
webView = WKWebView()
webView.navigationDelegate = self
view = webView
}

当网页打开时,我可以看到之前 View 中的导航栏遮挡了我的某些网页。

如何调整代码中的 View ,使我的网页显示在导航栏下方?

enter image description here

最佳答案

你应该为你的 webview 添加一个顶部约束并给它一个适合你的常量值(如果你想添加边距)

    webView.translatesAutoresizingMaskIntoConstraints = false
webView.topAnchor.constraint(equalTo: parentView.topAnchor, constant: 40).isActive = true

您还应该添加剩余的 anchor 值。

    webView.bottomAnchor.constraint(equalTo: parentView.bottomAnchor, constant: 0).isActive = true
webView.trailingAnchor.constraint(equalTo: parentView.trailingAnchor, constant: 0).isActive = true
webView.leadingAnchor.constraint(equalTo: parentView.leadingAnchor, constant: 0).isActive = true

关于ios - 如何将 View 高度调整到 iOS 中的导航栏下方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52068804/

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