如何在SwiftUI的导航栏中添加“子标题”之类的内容?

“我的”解决方案:

借助Midhun MPMojtaba Hosseini的帮助,我找到了此解决方案。可以,但是导航栏的半透明效果不再起作用。因此,如果有人知道如何修复它,请告诉我。

// UITableView.appearance().backgroundColor = UIColor(named: "CustomTableViewBackgroundColor") // These are all custom color sets
// UITableViewCell.appearance().backgroundColor = UIColor(named: "CustomTableViewCellBackgroundColor")

// For the navigation bar color
UINavigationBar.appearance().backgroundColor = UIColor(named: "CustomNavigationBarBackgroundColor")
UINavigationBar.appearance().setBackgroundImage(UIImage(),for: .default)

return VStack(spacing: 0) {
    // This is the "subheader"
    Text("Test")
        .padding(.top,9.5)
        .padding(.bottom,8)
        .frame(minWidth: 0,maxWidth: .infinity)
        .background(Color("CustomNavigationBarBackgroundColor")) // This is also a custom color set
        .font(.footnote)
    // And here is my normal NavigationView
    NavigationView {
        List {
            Text("Hello")
        } .listStyle(GroupedListStyle())

        .navigationBarTitle(Text(""),displayMode: .inline)
        .navigationBarBackButtonHidden(true)
        .navigationBarItems(
            leading:
            Button("Cancel") {
                // self.presentationmode.wrappedValue.dismiss()
            }.padding(.vertical,5),trailing:
            Button("Done") {

            }.padding(.vertical,5).disabled(true)
        )
    }
}

如何在SwiftUI的导航栏中添加“子标题”之类的内容?

我的原始问题:

我想在导航栏中插入类似的内容。因此,如果有人可以帮助我,那就太好了。

如何在SwiftUI的导航栏中添加“子标题”之类的内容?

现在我的代码

NavigationView {
    List {
        Text("Hello")
    } .listStyle(GroupedListStyle())

    .navigationBarTitle(Text(""),displayMode: .inline)
    .navigationBarBackButtonHidden(true)
    .navigationBarItems(
        leading:
        Button("Cancel") {
            self.presentationmode.wrappedValue.dismiss()
        },trailing:
        Button("Done") {

        }.disabled(true)
    )
}

以及我的代码如何编译的照片

如何在SwiftUI的导航栏中添加“子标题”之类的内容?

lichenguse 回答:如何在SwiftUI的导航栏中添加“子标题”之类的内容?

您可以在导航视图之前添加文本。

    <div class="textbkStyle">Renewal/Expiration Date:
        <div class="responseText">


                NOT AVAILABLE

        </div>
    </div>

注意:如果转到详细信息页面,以上子标签仍将可见。如果您不想这样做,则可以使用普通视图创建自定义标头。

本文链接:https://www.f2er.com/3164934.html

大家都在问