我想删除侧面的灰色条,但我不知道该怎么做。
我尝试了许多解决方案,例如:
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 。
最佳答案
您正在使用 测试您的项目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/