Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set width and height of an image in SwiftUI?

Tags:

swift

swiftui

I am trying to set height and width of an image . I've tried using following code but it didn't work.

 Image("testImg")
  .frame(width: 50, height: 50)
like image 874
Divya Vohra Avatar asked Dec 31 '22 10:12

Divya Vohra


2 Answers

Try this

Image("testImg")
.resizable()
.frame(width: 50.0, height: 50.0)
like image 161
Chaman Sharma Avatar answered Jan 12 '23 06:01

Chaman Sharma


Image(restaurant.image)
            .resizable()
            .frame(width: 40, height: 40)
            .clipShape(Circle())
like image 39
Hardik Bar Avatar answered Jan 12 '23 05:01

Hardik Bar