iOS:如何删除侧面的灰色条?

标签 ios webview view uiwebview cgrect

我想删除侧面的灰色条,但我不知道该怎么做。
我尝试了许多解决方案,例如:

enter image description here

 self.webView.frame = self.view.bounds
 self.webView.scalesPageToFit = true
 webView = UIWebView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height))

但是没有任何效果...

编辑:换成白色更好,但我想要一个真正的全屏 WebView 。
enter image description here

最佳答案

您正在使用 测试您的项目iPhone X (或类似),其中有 顶部和底部安全区域边距 (或这种情况下的左右边距,因为您在横向模式下使用它)。

您可以使用 自动布局 引擎来设置您的 View 布局,执行以下操作:

NSLayoutConstraint.activate([
    self.webView.topAnchor.constraint(equalTo: self.view.topAnchor),
    self.webView.rightAnchor.constraint(equalTo: self.view.rightAnchor),
    self.webView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
    self.webView.leftAnchor.constraint(equalTo: self.view.leftAnchor)
]);

Reference to Apple documentation about: "Adaptivity and Layout"

关于iOS:如何删除侧面的灰色条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54825804/

相关文章:

ios - Xamarin iOS : Pass credentials over http

ios - 选择具有两个按钮的 TableView 时更新数组时出错

java - 可以加载到 Android WebView 中的最大 html 文件是多少?

javascript - 使用 Webview Android 处理回调

objective-c - objective-c - 取消 NSOperationQueue 中的操作

iphone - 扩展 NKIssue - NewsStandKit (iOS)

ios - 在 Nest API iOS 中成功注销后如何重新加载登录页面

iOS 快速传递来自不同 View Controller 的信息

android - View 显示在另一个 View 下方,该 View 在 Android 中具有较低的海拔

django - 如何使用UpdateView更新Django模型?