5

如何在 SwiftUI 中为图像设置固定大小?目前我的形象真的很大

目前我有这个结构:

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

2 回答 2

9

一种方法是通过

profileImage.resizable().frame(width: 50, height: 50)
于 2019-06-04T22:18:18.870 回答
1
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.

图像1

图2

图3

于 2019-06-06T11:40:49.157 回答