How to resize Image with SwiftUI?

前端 未结 14 582
清歌不尽
清歌不尽 2020-12-23 19:54

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(roo         


        
14条回答
  •  再見小時候
    2020-12-23 20:50

    If you want to use aspect ratio with resizing then you can use following code:

    Image(landmark.imageName).resizable()
                    .frame(width: 56.0, height: 56.0)
                    .aspectRatio(CGSize(width:50, height: 50), contentMode: .fit)
    

提交回复
热议问题