隐藏导航栏 Swiftui
Hide navigation bar Swiftui
我在 SwiftUI 中的 NavigationView 有问题,我添加了这段代码来隐藏导航并且工作正常但是在滚动视图时出现粘性 header 如何删除它?谢谢!!
NavigationView {
...
}
.navigationBarTitle("")
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
在 NavigationView 中移动 navigationBarTitle 和 navigationBarHidden 将移除粘性 header。这是代码。
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)
}
}
我在 SwiftUI 中的 NavigationView 有问题,我添加了这段代码来隐藏导航并且工作正常但是在滚动视图时出现粘性 header 如何删除它?谢谢!!
NavigationView {
...
}
.navigationBarTitle("")
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
在 NavigationView 中移动 navigationBarTitle 和 navigationBarHidden 将移除粘性 header。这是代码。
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)
}
}