Created
February 15, 2020 17:28
-
-
Save gfontenot/de4ce242f571d14823b6c10b3872779b to your computer and use it in GitHub Desktop.
Swift UI sample of layout bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The result here is a very weird gap (black) between the navigation bar (gray w/ done button) and the web content (white):