Home > AI > IOS > SwiftUI >

SudokuView

SudokuView is a combination of 9 subviews with 3 rows and 3 columns.

Method 1: using GridView

struct ContentView: View {
    
    @EnvironmentObject var home: HomeGlobal

    
    let freeLayout = [
        GridItem(.flexible(), spacing: 16),
        GridItem(.flexible(), spacing: 16),
        GridItem(.flexible(), spacing: 16)
    ]
    
   
    
    var body: some View {
        VStack(alignment: .leading) {
            Text("免费课")
            LazyVGrid(columns: freeLayout, spacing:self.home.defaultPadding) {
                ForEach(ExperienceModel.freeCourse, id: \.self) { item  in
                    NavigationLink(
                        destination: Text("Destination"),
                        label: {
                            ExpImageView(name: "\(item)")
                        })
                }
            }
        }
    }
}

Leave a Reply