繁体   English   中英

如何在swiftUI中将图像设置为全屏?

[英]how can set image to fullscreen in swiftUI?

如何在swiftUI中将图像设置为全屏?

我试过用这个方法

background(Image("aa").frame(maxWidth: .infinity, maxHeight: .infinity).edgesIgnoringSafeArea(.all))

或者

.background(Image("aa").aspectRatio(contentMode: .fill).edgesIgnoringSafeArea(.all))

它没有全屏显示。

这是原始图像

在此处输入图片说明

但是,我总是显示这个......

在此处输入图片说明

哪里有问题?

如果图像大于屏幕,请使用.scaleToFil()

https://developer.apple.com/documentation/swiftui/view/scaledtofit()

Image("aa")
.resizable()
.scaledToFit()

如果图像小于屏幕,请使用.scaledToFil()

https://developer.apple.com/documentation/swiftui/view/scaledtofill()

Image("aa")
.resizable()
.scaledToFil()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM