Skip to content

Instantly share code, notes, and snippets.

@gfontenot
Created February 15, 2020 17:28
Show Gist options
  • Save gfontenot/de4ce242f571d14823b6c10b3872779b to your computer and use it in GitHub Desktop.
Save gfontenot/de4ce242f571d14823b6c10b3872779b to your computer and use it in GitHub Desktop.
Swift UI sample of layout bug
import SwiftUI
struct Sample: View {
var body: some View {
NavigationView {
WebView(url: URL(string: "https://example.com")!)
.navigationBarItems(
trailing: Button(
action: { },
label: { Text("Done") }
)
)
}
}
}
import WebKit
struct WebView: UIViewRepresentable {
let url: URL
func makeUIView(
context: UIViewRepresentableContext<WebView>
) -> WKWebView {
return WKWebView()
}
func updateUIView(
_ view: WKWebView,
context: UIViewRepresentableContext<WebView>
) {
view.load(URLRequest(url: url))
}
}
struct Sample_Previews: PreviewProvider {
static var previews: some View {
Sample()
}
}
@gfontenot
Copy link
Author

The result here is a very weird gap (black) between the navigation bar (gray w/ done button) and the web content (white):

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment