将固定大小设置为图像
Set fixed size to Image
如何在 SwiftUI 中为图片设置固定大小?目前我的图片很大
目前我有这个结构:
struct TweetCell: View {
var profileImage: Image
var body: some View {
HStack {
profileImage
VStack {
...
}
}
}
}
一种方法是通过
profileImage.resizable().frame(width: 50, height: 50)
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.
如何在 SwiftUI 中为图片设置固定大小?目前我的图片很大
目前我有这个结构:
struct TweetCell: View {
var profileImage: Image
var body: some View {
HStack {
profileImage
VStack {
...
}
}
}
}
一种方法是通过
profileImage.resizable().frame(width: 50, height: 50)
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.