我在SwiftUI中的NavigationView遇到问题,我添加了此代码以隐藏导航并可以正常工作,但是在滚动视图时出现粘性标头如何将其删除?谢谢!
NavigationView {
...
}
.navigationBarTitle("")
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
答案 0 :(得分:3)
在NavigationView中移动navigationBarTitle和navigationBarHidden将删除粘性标头。这是代码。
import SwiftUI
struct ContentView: View {
let months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December","January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
var body: some View {
NavigationView {
List(months, id: \.self) { month in
NavigationLink(destination: DetailView(month: month)) {
Text(month)
}
}
.navigationBarTitle("")
.navigationBarHidden(true)
}
//.navigationBarBackButtonHidden(true)
}
}
struct DetailView: View {
let month: String
var body: some View {
Text(month)
}
}