【发布时间】:2020-09-20 06:45:48
【问题描述】:
在我转到一个视图后,在后退按钮中,人字形图像旁边,导航栏标题显示在它之后。我怎样才能删除它但保持navigationBarTittle?我试过navigationBarBackButtonHidden,但没用。
更新
我补充说:
@State private var active: Bool = false
和
.navigationBarTitle(!active ? "Buscar" : "")
当我单击按钮时,另一个视图看起来像我想要的那样,但随后一切都变成了白色。
代码如下:
@EnvironmentObject var session: SessionStore
@Environment(\.colorScheme) var colorScheme
init() {
UINavigationBar.appearance().backIndicatorImage = UIImage(systemName: "chevron.left")
UINavigationBar.appearance().backIndicatorTransitionMaskImage = UIImage(systemName: "chevron.left")
}
@State private var active: Bool = false
var body: some View {
NavigationView {
VStack(spacing: 0) {
ScrollView(.vertical, showsIndicators: false) {
VStack(spacing: 18) {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 20) {
Text("teste")
.frame(height: 180)
.frame(width: 330)
.background(Color.blue)
.cornerRadius(15)
Text("teste")
.frame(height: 180)
.frame(width: 330)
.background(Color.green)
.cornerRadius(15)
Text("teste")
.frame(height: 180)
.frame(width: 330)
.background(Color.pink)
.cornerRadius(15)
}.padding(.horizontal, 12)
}
ForEach(specialtyList, id: \.type) { specialty in
NavigationLink(destination: SearchBar(item: specialty), isActive: self.$active) {
VStack(spacing: 18) {
HStack {
Text(specialty.type).foregroundColor(.white)
specialty.image
.renderingMode(.original)
.resizable()
.frame(width: 35, height: 35)
}.frame(minWidth: 0, idealWidth: 350, maxWidth: .infinity)
.frame(height: 100)
}
}.padding(.horizontal)
.background(specialty.color).cornerRadius(45)
}.padding(.horizontal)
}
.padding(.top)
.padding(.bottom)
}
}.navigationBarTitle(!active ? "Buscar" : "")
}.accentColor(colorScheme == .dark ? Color.white : Color.black)
}
【问题讨论】:
-
1) 它与您的previous question 有何不同? Asperi 的回答应该足以解决您的问题 2)如果确实是另一个问题,请创建一个Minimal, Reproducible Example
-
我无法实现之前代码中的所有功能。
标签: navigation swiftui