I'm trying to use SwiftUI to build something along the lines of a header/content/footer with a VStack. I'd like the header and footer to take up 10% each of the height of the screen, and the content to expand to fill up the rest. This pattern could be useful for things other than header/content/footer, so if there's already something that implements this pattern (middle view expanding, or something along those lines), that would be great...
This is probably super simple to experienced swift devs, but I can't seem to find an example of it anywhere.
Any advice/pointers/code would be greatly appreciated!
My existing, super-simple code, with all of my experiments removed:
import SwiftUI
struct ContentView: View {
var body: some View {
VStack() {
Header()
Content()
Footer()
}
.frame(minWidth: 0,
maxWidth: .infinity,
minHeight: 0,
maxHeight: .infinity,
alignment: Alignment.topLeading)
.border(Color.red)
}
}
struct Header: View {
var body: some View {
HStack() {
Text("Header")
}
.padding()
.border(Color.blue)
}
}
struct Content: View {
var body: some View {
HStack() {
Text("Content")
}
.padding()
.border(Color.black)
}
}
struct Footer: View {
var body: some View {
HStack() {
Text("Footer")
}
.padding()
.border(Color.green)
}
}
