1 | initial version |
To create a muted background in SwiftUI, you can follow the following process:
Here is an example code snippet that creates a muted background:
struct ContentView: View {
var body: some View {
ZStack {
Rectangle()
.foregroundColor(Color.gray.opacity(0.5))
.edgesIgnoringSafeArea(.all)
Text("Hello, world!")
.font(.largeTitle)
.fontWeight(.bold)
}
}
}
In this example, the Rectangle with a gray color is set as the background view by adding it to the ZStack with .edgesIgnoringSafeArea(.all)
to make it cover the entire screen. The Text
component, which represents the content of the screen, is placed on top of the Rectangle.