how to add background color to shapes in swiftui code example
Example 1: how to put background image in swiftui
var body: some View {
TabbedView(selection: $selection, content: {
VStack {
Text("TEST 0")
.background(Color.clear)
}
.tabItemLabel(Text("Simple Center"))
.tag(0)
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)
})
.background(
Image("background-gradient")
.resizable()
.scaledToFill()
)
.padding()
}
Example 2: shapes in swiftui
struct ContentView: View {
var body: some View {
ZStack {
Rectangle()
.fill(Color.black)
.frame(width: 200, height: 200)
RoundedRectangle(cornerRadius: 25, style: .continuous)
.fill(Color.red)
.frame(width: 200, height: 200)
Capsule()
.fill(Color.green)
.frame(width: 100, height: 50)
Ellipse()
.fill(Color.blue)
.frame(width: 100, height: 50)
Circle()
.fill(Color.white)
.frame(width: 100, height: 50)
}
}
}