问题描述
在 LazyVGrid
中,我显示来自服务器的数据(这里我以字母表为例),我的目标是在中心显示最后一行而不是 leading
如果最后一行包含少于 3 个项目。可行吗?
目前,它看起来像这样:
struct ContentView: View {
let alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
let preference = [
GridItem(.flexible()),GridItem(.flexible()),GridItem(.flexible())
]
var body: some View {
ScrollView {
LazyVGrid(columns: preference) {
ForEach(alphabet,id: \.self) { value in
ZStack {
Rectangle()
.frame(width: 120,height: 120)
.foregroundColor(Color(UIColor.systemIndigo))
.cornerRadius(16)
Text(value.description)
.foregroundColor(.white)
.font(.title)
}
}
}
}
}
}
目标:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)