0

导航栏标题已隐藏。在这种状态下如何显示后退按钮?

struct SampleView: View {
    var body: some View {
        ScrollView() {
            Text("text")
        }
        .navigationBarTitle("")
        .navigationBarHidden(true)
    }
}

当您执行以下操作时,顶部会出现一个空白。此外,如果滚动,将显示一个栏。

struct SampleView: View {
    var body: some View {
        ScrollView() {
            Text("text")
        }
        .navigationBarTitle("")
    }
}

在此处输入图像描述

4

1 回答 1

2

这是添加自定义按钮而不是导航栏的方法

struct DestinationView: View {

    @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
    var body: some View {

        VStack(alignment: .center, spacing: 0){
        Button(action: {
           self.presentationMode.wrappedValue.dismiss()
        }) {
            Image(systemName: "backward.fill").padding()
            Spacer()
        }
            Spacer()
        }
        .navigationBarTitle("")
        .navigationBarHidden(true)

    }
}

在此处输入图像描述

于 2020-03-04T17:34:29.127 回答