Swiftui 带vstack的全屏背景图像
我希望有一个带有navigationview的全屏背景图像(必须在顶部,因为它来自基本视图,通常不在“此”视图中)。 在这个视图中,我想要一个VStack,它就在安全区域内,所以在navigationbar和底部布局之间 不幸的是我得到了(见图) 我期待里面的文字Swiftui 带vstack的全屏背景图像,swiftui,vstack,Swiftui,Vstack,我希望有一个带有navigationview的全屏背景图像(必须在顶部,因为它来自基本视图,通常不在“此”视图中)。 在这个视图中,我想要一个VStack,它就在安全区域内,所以在navigationbar和底部布局之间 不幸的是我得到了(见图) 我期待里面的文字 这是一个稍加修改的变体。使用Xcode 11.4(最终发布)/iOS 13.4进行测试 struct TestFullScreenImage: View { var body: some View { Navi
这是一个稍加修改的变体。使用Xcode 11.4(最终发布)/iOS 13.4进行测试
struct TestFullScreenImage: View {
var body: some View {
NavigationView {
ZStack {
Image("large_image")
.resizable()
.edgesIgnoringSafeArea(.all)
.scaledToFill()
VStack {
Text("Just a test")
.font(.largeTitle)
.foregroundColor(.white)
Spacer()
Text("centered")
.font(.largeTitle)
.background(Color.green)
}
.navigationBarTitle("Navigation Title")
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
struct TestFullScreenImage: View {
var body: some View {
NavigationView {
ZStack {
Image("large_image")
.resizable()
.edgesIgnoringSafeArea(.all)
.scaledToFill()
VStack {
Text("Just a test")
.font(.largeTitle)
.foregroundColor(.white)
Spacer()
Text("centered")
.font(.largeTitle)
.background(Color.green)
}
.navigationBarTitle("Navigation Title")
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}