美文网首页
2022-03-19 LazyVGrid

2022-03-19 LazyVGrid

作者: 脑子 | 来源:发表于2022-03-20 18:08 被阅读0次

    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()
        }
    

    相关文章

      网友评论

          本文标题:2022-03-19 LazyVGrid

          本文链接:https://www.haomeiwen.com/subject/xjondrtx.html