我有一张图片,我只想拉伸它的高度以适合不同的内容,我该如何在swiftUI中做到这一点?
Image("rightTag")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 20)
粗略的可调整大小,无法完成。任何帮助都会很棒!谢谢!
我不确定我是否正确理解了您的目标,但似乎像下面这样
Image("auto") // << your image here
.resizable()
.aspectRatio(contentMode: .fill)
.frame(maxWidth: 20, alignment: .leading) // ?? not sure about alignment for you,
// but this gives left-size 20 pt of image
// .clipped() // << uncomment if needed