什么SwiftUI
相当于UIImageView
aspectFill
选项?
当我做
Image(self.chat.thumbnailName)
.resizable()
.frame(width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width)
.clipped()
Run Code Online (Sandbox Code Playgroud)
(也尝试添加.aspectRatio(contentMode: .fill)
或.aspectRatio(contentMode: .fit)
我仍然得到一个丑陋的扭曲图像:
根据需要使用.scaledToFill
或.scaledToFit
修饰符。所以在你的情况下
Image(self.chat.thumbnailName)
.resizable()
.scaledToFill()
.frame(width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.width)
.clipped()
Run Code Online (Sandbox Code Playgroud)