SwiftiSwift
SwiftiSwift

Reputation: 8707

Set fixed size to Image

How can I set a fixed size for an Image in SwiftUI? Currently my Image is really big

At the moment I have this structure:

struct TweetCell: View {
     var profileImage: Image
     var body: some View {
         HStack {
              profileImage
             VStack {
            ...
         }
    }
  }
}

Upvotes: 5

Views: 5311

Answers (2)

CrazyPro007
CrazyPro007

Reputation: 1062

There are multiple ways to set fixed size to Image

1) Image("yourImage").frame(width: 25, height: 25, alignment: .center)

2) Image("yourImage").resizable().frame(width: 25, height: 25, alignment: .center)
3) Image("yourImage").frame(width: 25, height: 25, alignment: .center).clipped()

Attached the screenshots for all.

image1

image2

image3

Upvotes: 1

tsp
tsp

Reputation: 1976

One way of doing it is via

profileImage.resizable().frame(width: 50, height: 50)

Upvotes: 10

Related Questions