是否可以将覆盖层放置在NavigationBarTitle /后退按钮的顶部?在此示例中,我希望灰色矩形隐藏navigationBarTitle和“后退”按钮。
import SwiftUI
struct ContentView: View {
var body: some View {
EmptyView()
.sheet(isPresented: .constant(true)){
NavigationView{
NavigationLink(destination: MyView(), label: {Text("Go to view")})
}
}
}
}
struct MyView: View {
var body: some View{
VStack{
HStack{
Spacer()
Rectangle()
.frame(width: 400, height: 100)
.foregroundColor(.gray)
.offset(y: -100)
Spacer()
}
Spacer()
}
.zIndex(100) //doesn't do anything
.navigationBarTitle("View")
}
}