This is about filling a background with a color.
I am building a SwiftUI version of this project. It's a tabbed app (test harness).
The first thing that I'm doing, is setting the tabs up. I expect to be learning a lot, and hitting a lot of walls.
The first wall, is that I fill the app background with a (ghastly) virulent green background gradient.
This takes the form of a stripe that I stretch horizontally.
With IB, not an issue.
With SwiftUI, I need to figure it out.
Here's the code I have so far:
import SwiftUI
struct RVS_SpinnerSwiftUI_Tabbed_Test_Harness_ContentView: View {
@State private var selection = 0
var body: some View {
TabbedView(selection: $selection, content: {
VStack {
Text("TEST 0")
.background(Color.clear)
}
.tabItemLabel(Text("Simple Center"))
.tag(0)
.background(Image("background-gradient")
.scaledToFill()
// .scaledToFit()
)
VStack {
Text("TEST 1")
.background(Color.clear)
}
.tabItemLabel(Text("Bottom Right"))
.tag(1)
.background(Color.clear)
VStack {
Text("TEST 2")
.background(Color.clear)
}
.tabItemLabel(Text("Rotator"))
.tag(2)
VStack {
Text("TEST 3")
.background(Color.clear)
}
.tabItemLabel(Text("Quadrants"))
.tag(3)
.background(Color.clear)
})
.padding()
}
}
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
RVS_SpinnerSwiftUI_Tabbed_Test_Harness_ContentView()
}
}
#endif
The issue is with .background(Image("background-gradient"))
in the first tab. I am using this to prototype the operation. Once I figure everything out, I'll be making this work more sensibly.
It's likely to change over time, so I understand if people want me to nuke the link, but it does allow folks to see it in place (for now).
I'm interested in figuring out how to stretch the background image horizontally to fill the tab.
.resizable
.