默认情况下,使用 ScrollView 时,其中的视图分布在整个屏幕宽度上,但使用 List 时,两侧有填充。有没有办法摆脱这种填充?
Asp*_*eri 13
要实现这一点,您需要将ForEach
insideList
与.listRowInsets
下面的示例结合使用
struct Demo: View {
var colors: [Color] = [.red, .blue, .yellow]
var body: some View {
List {
ForEach(colors, id: \.self) { color in
color
}.listRowInsets(EdgeInsets())
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1531 次 |
最近记录: |