How to resize Image with SwiftUI?
How about this:
struct ResizedImage: View {
var body: some View {
Image("myImage")
.resizable()
.scaledToFit()
.frame(width: 200, height: 200)
}
}
The image view is 200x200, but the image maintains the original aspect ratio (rescaling within that frame).
You should use .resizable()
before applying any size modifications on an Image
.
Image(room.thumbnailImage)
.resizable()
.frame(width: 32.0, height: 32.0)