How to adjust an image size in a list

Hello folks,


I'm very new to SwiftUI and I have trouble resizing images in a List.

So far, I created an List like this:


var body: some View {

List(rooms) { room in

Image(room.thumbnailName) <- this image is original size 1920x1080.

VStack(alignment: .leading) {

Text(room.name)

Text("\(room.capacity) people")

.font(.subheadline)

.foregroundColor(.secondary)

}

}

}


Because the original image size is 1920x1080, the List looks very weird.


My question: Does anyone of you know how I can resize the image by a property of the imageview so that the List looks accurate?


Many thanks in advance.


Kind regards


CX8060

Did you try:


Image(room.thumbnailImage).resizable()
.frame(width: 32.0, height: 32.0)


Of course set the size as needed.


Look here for other options, such as scaleToFit.

https://stackoverflow.com/questions/56505692/how-to-resize-image-with-swiftui

How to adjust an image size in a list
 
 
Q