Warm tip: This article is reproduced from stackoverflow.com, please click
ios swift swiftui

How to resize Image with SwiftUI?

发布于 2020-04-05 23:40:19

I have a large image in Assets.xcassets. How to resize this image with SwiftUI to make it small?

I tried to set frame but it doesn't work:

Image(room.thumbnailImage)
    .frame(width: 32.0, height: 32.0)
Questioner
subdan
Viewed
71
rraphael 2019-06-08 19:00

You should use .resizable() before applying any size modifications on an Image.

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