UICollectionView and SwiftUI?

后端 未结 16 1478
时光说笑
时光说笑 2020-12-02 07:32

How to create grid of square items (for example like in iOS Photo Library) with SwiftUI?

I tried this approach but it doesn\'t work:

var body: some          


        
16条回答
  •  一个人的身影
    2020-12-02 07:44

    Thinking in SwiftUI, there is a easy way :

    struct MyGridView : View {
    var body: some View {
        List() {
            ForEach(0..<8) { _ in
                HStack {
                    ForEach(0..<3) { _ in
                        Image("orange_color")
                            .resizable()
                            .scaledToFit()
                    }
                }
            }
        }
    }
    

    }

    SwiftUI enough if you want,you need forgot such as UIColectionView sometimes..

提交回复
热议问题