How to resize Image with SwiftUI?

前端 未结 14 630
清歌不尽
清歌不尽 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:32

    Well, It's seems pretty easy in SwiftUI / Following the demo they given : https://developer.apple.com/videos/play/wwdc2019/204

    struct RoomDetail: View {
         let room: Room
         var body: some View {
    
         Image(room.imageName)
           .resizable()
           .aspectRatio(contentMode: .fit)
     }
    

    Hope it helps.

提交回复
热议问题