SwiftUI 标签视图修复
SwiftUI Tabview Fix
在我的应用程序中,我有一个选项卡视图。其中 4 个标签是空白页。没有清单或任何东西。其中之一有一个列表,并且由于滚动功能使标签栏半透明。问题是,每当我离开列表页面时,半透明的标签栏都会保留。我不想这样。我希望它恢复透明。如果您查看“照片”应用程序,它会执行此操作。它很容易从透明变为半透明,然后变回透明。
var body: some View {
TabView(selection: $selectedTab) {
Schedule()
.tag(Tab.schedule)
.tabItem {
Label("Schedule", systemImage: "calendar")
}
Messaging()
.tag(Tab.messaging)
.tabItem {
Label("Messaging", systemImage: "bubble.left")
}
Dashboard()
.tag(Tab.home)
.tabItem {
Label("Dashboard", systemImage: "note")
}
Resources()
.tag(Tab.resources)
.tabItem {
Label("Resources", systemImage: "folder")
}
MailViewTest()
.tag(Tab.settings)
.tabItem {
Label("Settings", systemImage: "gear")
}
}
如果你看这个视频,我会展示它是如何停留的,但是当我滚动列表时,它就消失了。
尝试重置TabView
,喜欢
TabView(selection: $selectedTab) {
// other code
}
.id(selectedTab) // << here !!
在我的应用程序中,我有一个选项卡视图。其中 4 个标签是空白页。没有清单或任何东西。其中之一有一个列表,并且由于滚动功能使标签栏半透明。问题是,每当我离开列表页面时,半透明的标签栏都会保留。我不想这样。我希望它恢复透明。如果您查看“照片”应用程序,它会执行此操作。它很容易从透明变为半透明,然后变回透明。
var body: some View {
TabView(selection: $selectedTab) {
Schedule()
.tag(Tab.schedule)
.tabItem {
Label("Schedule", systemImage: "calendar")
}
Messaging()
.tag(Tab.messaging)
.tabItem {
Label("Messaging", systemImage: "bubble.left")
}
Dashboard()
.tag(Tab.home)
.tabItem {
Label("Dashboard", systemImage: "note")
}
Resources()
.tag(Tab.resources)
.tabItem {
Label("Resources", systemImage: "folder")
}
MailViewTest()
.tag(Tab.settings)
.tabItem {
Label("Settings", systemImage: "gear")
}
}
如果你看这个视频,我会展示它是如何停留的,但是当我滚动列表时,它就消失了。
尝试重置TabView
,喜欢
TabView(selection: $selectedTab) {
// other code
}
.id(selectedTab) // << here !!