0
The bug is “row”
Let boardersize = CGFloat(5) VStack(spacing:boardersize) { For each(0…2, id(): \.self) } row; in HStack(spacing:boarder size) { For each(0…2, id(): \.self) {
4 Antworten
+ 5
Looks like you are trying to create a board game with a 3x3 grid of cells.
Without more context or information about the error you are experiencing, it is difficult to provide a specific solution.
you can however modify the row in the code you posted like this.
let boarderSize = CGFloat(5)
VStack(spacing:boarderSize) {
ForEach(0...2, id: \.self) { row in
HStack(spacing:boarderSize) {
ForEach(0...2, id: \.self) { column in
// create a cell here
}
}
}
}
+ 5
To create a cell , you can use the List view and provide it with a data source and a closure that returns a view for each element in the data source.
Here's an example of how you might create a simple cell in a list:
struct MyCell: View {
let title: String
var body: some View {
Text(title)
}
}
struct MyList: View {
let data: [String]
var body: some View {
List(data, id: \.self) { title in
MyCell(title: title)
}
}
}
0
How do i create the cell
0
Example please