【发布时间】:2022-02-14 04:55:08
【问题描述】:
我已经尝试this 尝试单独更改选项卡图标的颜色,但由于某种原因,颜色会正确修改,然后点击返回图标后,它不会显示自定义颜色。
如何更改每个单独选项卡的选项卡项目图标(每个选项卡的颜色不同)?
这是包含我正在尝试修改的 TabView 的视图的代码。
struct MainView: View {
@AppStorage("PendingOnboarding") var pendingOnboarding = true
init() {
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor(Color.recyclepediaGreen)
}
var body: some View {
NavigationView {
ZStack {
TabView {
CurbsideView()
.tabItem {
Label("Curbside", systemImage: "car.fill")
}
ItemsView()
.tabItem {
Label("Items", systemImage: "archivebox.fill")
}
LearnView()
.tabItem {
Label("Learn", systemImage: "info.circle.fill")
}
ContactUsView()
.tabItem {
Label("Contact Us", systemImage: "phone.fill.connection")
}
}
.accentColor(Color.recyclepediaBlue)
.toolbar {
ToolbarItem(placement: .principal) {
Image("Recyclepedia")
.resizable()
.scaledToFit()
.padding(.top, 5)
.padding(.bottom, 5)
}
}
}
.popup(isPresented: $pendingOnboarding, dragToDismiss: false, closeOnTap: false, backgroundColor: Color.white) {
OnboardingView(pendingOnboarding: $pendingOnboarding)
}
}
}
}
【问题讨论】: