Swiftui 全尺寸图片有白色边框,为什么?
我这里有代码,上面有白色的“边框”,我不想要。 有人知道我为什么会得到它以及如何摆脱它吗Swiftui 全尺寸图片有白色边框,为什么?,swiftui,Swiftui,我这里有代码,上面有白色的“边框”,我不想要。 有人知道我为什么会得到它以及如何摆脱它吗 @available(iOS 13.0, *) struct PicTest_Previews: PreviewProvider { static var previews: some View { ZStack { VStack { Text("a") .font(.largeTit
@available(iOS 13.0, *)
struct PicTest_Previews: PreviewProvider {
static var previews: some View {
ZStack {
VStack {
Text("a")
.font(.largeTitle)
.background(Color.red)
Text("b")
.font(.largeTitle)
.background(Color.green)
}
}.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
.background(Image("laguna")
.resizable()
.scaledToFill())
}
}
开始了
static var previews: some View {
ZStack {
VStack {
Text("a")
.font(.largeTitle)
.background(Color.red)
Text("b")
.font(.largeTitle)
.background(Color.green)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity) // << here !!
.background(
Image("large_image")
.resizable()
.edgesIgnoringSafeArea(.all) // << here !!
.scaledToFill()
)
}
静态var预览:一些视图{
ZStack{
VStack{
文本(“a”)
.font(.largeTitle)
.背景(颜色.红色)
文本(“b”)
.font(.largeTitle)
.背景(颜色.绿色)
}
}
.frame(maxWidth:.infinity,maxHeight:.infinity)//我不知道我可以将edgesIgnoringSafeArea设置为image,我总是设置为zstack或hstack…谢谢!!!