LazyVGrid 不访问卡片的全部
LazyVGrid(columns: [GridItem(.adaptive(minimum: 65))])
设定最小宽度为65,能放几个放几个,横向模式后也适用
LazyVGrid(columns: [GridItem(.fixed(200)), GridItem(.flexible()),GridItem()]) {
ForEach(emojis[0..<emojiCount], id: \.self) { emoji in
CardView(content: emoji)}
}
LazyVGrid(columns: [GridItem(), GridItem(),GridItem()]) {
ForEach(emojis[0..<emojiCount], id: \.self) { emoji in
CardView(content: emoji)}
.aspectRatio(2/3, contentMode: .fit)
}
.foregroundColor(.red)
Spacer()
//宽度2/3 填充
var body: some View {
VStack {
//ScrollView 滑块
ScrollView {
//LazyVGrid 自定义列数与高宽比例,aspectRatio 高宽比
LazyVGrid(columns: [GridItem(), GridItem(),GridItem()]) {
ForEach(emojis[0..<emojiCount], id: \.self) { emoji in
CardView(content: emoji)}
.aspectRatio(2/3, contentMode: .fit)
}
}
.foregroundColor(.red)
Spacer()
HStack {
add
Spacer()
remove
}
.font(.largeTitle)
}
.padding()
}