When removing the window titlebar it makes sense that I can paint to the top of the window.
However with the window tab bar showing, the HSplitView doesn't stop at the window tab but goes straight over it.
How do I have the HSplitView stop at the bottom of the tab?
The issue is
TestApp.swift
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.windowStyle(HiddenTitleBarWindowStyle())
}
}
ContentView.swift
struct ContentView: View {
var body: some View {
NavigationView {
Text("Sidebar")
HSplitView {
Text("left")
.frame(maxWidth: .infinity, maxHeight: .infinity)
.navigationTitle("tab name")
Text("right")
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.toolbar {
Button(action: {}){
Image(systemName: "arrow.triangle.turn.up.right.diamond")
Text("Button 1")
}
}
}
}
}
Result (HSplitView goes all the way to the top of the window):
2 possible solutions that feel inadequate are
struct ContentView: View {
var body: some View {
NavigationView {
Text("Sidebar")
VStack(spacing: 0) {
Divider()
HSplitView {
Text("left")
.frame(maxWidth: .infinity, maxHeight: .infinity)
.navigationTitle("tab name")
Text("right")
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.toolbar {
Button(action: {}){
Image(systemName: "arrow.triangle.turn.up.right.diamond")
Text("Button 1")
}
}
}
}
}
}
Which results in this (however I don't want a divider below the tabs):
OR
struct ContentView: View {
var body: some View {
NavigationView {
Text("Sidebar")
VStack(spacing: 0) {
VStack {}
.frame(maxWidth: .infinity, maxHeight: 1)
HSplitView {
Text("left")
.frame(maxWidth: .infinity, maxHeight: .infinity)
.navigationTitle("tab name")
Text("right")
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.toolbar {
Button(action: {}){
Image(systemName: "arrow.triangle.turn.up.right.diamond")
Text("Button 1")
}
}
}
}
}
}
Which results in this (but I wonder if this is "accidentally" working):