例如,我有此视图:
import SwiftUI
struct TarifsScreen: View {
var body: some View {
GeometryReader { geometry in
VStack {
VStack {
Spacer()
Text("Text1")
Spacer()
Text("Text2")
Spacer()
Text("Text3")
Spacer()
}
}.frame(width: geometry.size.width, height: geometry.size.height).shadow(color: Color.white, radius: 10, x: 0, y: 0)
}
}
}
如何仅对VStack而不是对VStack内部的所有元素应用阴影?我可以用ZStack和两个容器来做吗?
[添加背景并对其施加阴影,如下例所示
VStack {
...
}
.background(Color.white // any non-transparent background
.shadow(color: Color.red, radius: 10, x: 0, y: 0)
)
.frame(width: geometry.size.width, height: geometry.size.height)