I'm using the new Swifty WebView in 26.0 beta (17A5241e).
Previously, I would wrap WKWebView
in a ViewRepresentable
and place it in the detail area of a NavigationSplitView
. The page content correctly shrunk when the sidebar was opened.
Now, the page content takes up the full width of the NavigationSplitView
and the sidebar hovers over the page content with a translucent effect. This is in spite of setting .navigationSplitViewStyle(.balanced)
. Code below.
I believe this is a problem with the new WebView not respecting size hints from parent views in the hierarchy. This is because if I replace the WebView with a centered Text
view, it shifts over correctly when the sidebar is opened.
struct OccludingNavSplitView: View {
var body: some View {
NavigationSplitView {
Text("Sidebar")
} detail: {
WebView(url: URL(string: "https://www.google.com")!)
}
.navigationSplitViewStyle(.balanced)
}
}
#Preview("Occluding sidebar") {
OccludingNavSplitView()
}