我用的是View
,它有一些按钮、一个阴影和一个后跟列表
问题是阴影在List中不可见,但在ScrollView中可见.
以下是我的代码截图:
struct ContentView: View {
var body: some View {
VStack(spacing: 0) {
HStack {
Button {
} label: {
Text("Button 1")
}
.frame(maxWidth: .infinity)
Divider()
.frame(height: 44)
Button {
} label: {
Text("Button 2")
}
.frame(maxWidth: .infinity)
}
.background(Color.white
.shadow(color: Color.gray, radius: 10, x: 0, y: 0)
.mask(Rectangle().padding(.bottom, -20))
)
List(0..<10) { index in
Text("Scrollable list")
}
.listStyle(PlainListStyle())
}
}
}
我必须将间距设为0,这样当列表滚动时,没有空格将是可见的
我想用列表来实现查看阴影.