Код: Выделить всё
struct ContentView: View {
var body: some View {
ZStack {
// Background rectangle with corner radius - Top rectangle is here only for the shadow
Rectangle()
.fill(Color.green)
.frame(width: 200 - 24, height: 20) // Width adjusted for padding
.padding(12) // Use half of the padding to align properly
.shadow(color: .gray, radius: 24, x: 0, y: 100) // Shadow for the top rectangle
.fixedSize(horizontal: true, vertical: false)
.padding()
Rectangle()
.fill(Color.blue)
.frame(width: 200, height: 200)
.cornerRadius(20) // Apply corner radius
// Text inside the blue rectangle
Text("This is some text")
.foregroundColor(.white) // Text color
.multilineTextAlignment(.center) // Center align text
.padding() // Padding inside the rectangle
.frame(maxWidth: .infinity, maxHeight: .infinity) // Allow text to occupy full space
}
.padding(20) // Padding for the ZStack
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... the-number