I would like to center the red rectangle vertically on the right side (the detail
part of the NavigationSplitView
). I can hide it with .toolbarBackground(.hidden, for: .windowToolbar)
, but the toolbar is still taking up space.
One way would be to figure out the toolbar height, but that has some other drawbacks for me.
Is there any way to get rid of the toolbar completely, in a way that keeps the sidebar toolbar but removes the detail one?
NavigationSplitView {
Color.orange
} detail: {
Color.red
.aspectRatio(18/9, contentMode: .fit)
.toolbar(removing: .title)
.toolbarBackground(.hidden, for: .windowToolbar)
}
Try applying a frame with maximum height of .infinity
to the detail view, to bring it into contact with the edges of the safe area. Then apply .ignoresSafeArea()
:
Color.red
.aspectRatio(18/9, contentMode: .fit)
.toolbar(removing: .title)
.toolbarBackground(.hidden, for: .windowToolbar)
.frame(maxHeight: .infinity) // 👈 here
.ignoresSafeArea() // 👈 and here