Skip to content

Commit a8496cf

Browse files
graycreateclaude
andcommitted
fix: simplify tab bar color configuration with accentColor
Simplify the tab bar color implementation: - Use UITabBar.appearance().unselectedItemTintColor for unselected items (both icons and text) - Use .accentColor(Color.primary) modifier on TabView for selected items - Remove complex UITabBarAppearance layout configurations This simpler approach should properly apply colors to both icons and text: - Light mode: selected=black, unselected=light gray (78%) - Dark mode: selected=white, unselected=dim gray (60%) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e743785 commit a8496cf

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

V2er/View/MainPage.swift

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ struct MainPage: StateView {
2525
}
2626

2727
init() {
28-
// Configure TabBar appearance using UIKit for unselected item color
29-
// This is the only way to set unselected item color in iOS 15+
30-
let appearance = UITabBarAppearance()
31-
appearance.configureWithDefaultBackground()
32-
33-
// Unselected item color - use specific colors for light/dark mode
28+
// Configure unselected item color using UITabBar.appearance()
29+
// Selected color is controlled by .accentColor() modifier on TabView
3430
let unselectedColor = UIColor { traitCollection in
3531
switch traitCollection.userInterfaceStyle {
3632
case .dark:
@@ -42,19 +38,7 @@ struct MainPage: StateView {
4238
}
4339
}
4440

45-
appearance.stackedLayoutAppearance.normal.iconColor = unselectedColor
46-
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: unselectedColor]
47-
48-
appearance.inlineLayoutAppearance.normal.iconColor = unselectedColor
49-
appearance.inlineLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: unselectedColor]
50-
51-
appearance.compactInlineLayoutAppearance.normal.iconColor = unselectedColor
52-
appearance.compactInlineLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: unselectedColor]
53-
54-
UITabBar.appearance().standardAppearance = appearance
55-
if #available(iOS 15.0, *) {
56-
UITabBar.appearance().scrollEdgeAppearance = appearance
57-
}
41+
UITabBar.appearance().unselectedItemTintColor = unselectedColor
5842
}
5943

6044
// Create an intermediate binding that captures all tab selections
@@ -118,7 +102,7 @@ struct MainPage: StateView {
118102
}
119103
.tag(TabId.me)
120104
}
121-
.tint(Color.primary) // Use primary color for selected items (black in light, white in dark)
105+
.accentColor(Color.primary) // This controls the selected icon color in TabView
122106

123107
// Filter menu overlay - only render when needed
124108
if state.selectedTab == .feed && store.appState.feedState.showFilterMenu {

0 commit comments

Comments
 (0)