Using SwiftUI, I am trying to center a View
on the screen and then give it a header and/or footer of variable heights.
Using constraints it would look something like this:
let view = ...
let header = ...
let footer = ...
view.centerInParent()
header.pinBottomToTop(of: view)
footer.pinTopToBottom(of: view)
This way, the view
would always be centered on the screen, regardless of the size of the header and footer.
I cannot figure out how to accomplish this with SwiftUI. Using any type of HStack
or VStack
means the sizes of the header
and footer
push around the view
. I would like to avoid hardcoding any heights since the center view
may vary in size as well.
Any ideas? New to SwiftUI so advice is appreciated!