SwiftUI覆盖在NavigationView / NavigationBarTitle

时间:2020-08-27 18:34:50

标签: swift swiftui

是否可以将覆盖层放置在NavigationBarTitle /后退按钮的顶部?在此示例中,我希望灰色矩形隐藏navigationBarTitle和“后退”按钮。

enter image description here

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")
    }
}

0 个答案:

没有答案