How to resize Image with SwiftUI?

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

    struct AvatarImage: View {
        var body: some View {
    
                Image("myImage")
                    .resizable()
                    .scaledToFill() // <=== Saves aspect ratio
                    .frame(width: 60.0, height:60)
                    .clipShape(Circle())
    
        }
    }
    

提交回复
热议问题