How I can make a square image similar to the photo gallery?
I'm trying the following:
let columns: [GridItem] = [
GridItem(.flexible()),
GridItem(.flexible())
]
LazyVGrid(
columns: columns,
alignment: .center
) {
ForEach(self.selectedImages, id: \.self) { image in
Image(uiImage: image)
.resizable()
.scaledToFit()
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.aspectRatio(1, contentMode: .fill)
.background(Color.blue)
}
}
However, this results in this:
I want to build a 2x2 square grid (similar to this 3x3 below - I want the images to fit nicely into the square)