“我的”解决方案:
借助Midhun MP和Mojtaba 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)
)
}
}
我的原始问题:
我想在导航栏中插入类似的内容。因此,如果有人可以帮助我,那就太好了。
现在我的代码
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)
)
}
以及我的代码如何编译的照片