如何从导航视图中删除顶部空间注意1:如果没有导航,它将显示全屏注意2:如果我在图像内部使用此[.edgesIgnoringSafeArea(.all)
),它将显示全屏显示,但图像无法正确填充,请检查两个图像视图。
这是我的代码:
var body: some View {
NavigationView {
GeometryReader { geometry in
ZStack {
Image("splash_screen")
.resizable()
.aspectRatio(geometry.size, contentMode: .fill)
// .edgesIgnoringSafeArea(.all)
//.frame(height: geometry.size.height)
}
}
}
.navigationBarHidden(true)
.navigationBarTitle("")
.navigationBarBackButtonHidden(true)
//.edgesIgnoringSafeArea([.top, .bottom])
.edgesIgnoringSafeArea(.all)
.background(Color .red)
}
与此兼容。将属性.scaledToFill()
添加到Imageview。
ZStack {
Image("LandingBg")
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
// .edgesIgnoringSafeArea(.all)
//.frame(height: geometry.size.height)
}