Skip to content

Commit 31b2270

Browse files
graycreateclaude
andcommitted
feat: improve tab bar color contrast in light and dark modes
Update tab bar unselected item color from 40% to 60% opacity for better contrast and visibility in both light and dark modes. Changes: - Light mode: selected uses dark color, unselected uses 60% opacity dark (was 40%) - Dark mode: selected uses white, unselected uses 60% opacity white (was 40%) The subtle difference (100% vs 60%) provides better visual feedback while maintaining a clean, modern look consistent with iOS design patterns. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 053bfdd commit 31b2270

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

V2er/View/MainPage.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,37 @@ struct MainPage: StateView {
2424
store.appState.feedState.feedInfo.unReadNums
2525
}
2626

27+
init() {
28+
// Configure TabBar appearance for better contrast in both light and dark modes
29+
let appearance = UITabBarAppearance()
30+
appearance.configureWithDefaultBackground()
31+
32+
// Set tint color for selected items
33+
// Light Mode: deep/dark color (from Color.tintColor)
34+
// Dark Mode: white (from Color.tintColor)
35+
UITabBar.appearance().tintColor = UIColor(Color.tintColor)
36+
37+
// Set color for unselected items with subtle difference from selected
38+
// Light mode: selected = dark color, unselected = slightly lighter dark color (60% opacity)
39+
// Dark mode: selected = white, unselected = slightly dimmed white (60% opacity)
40+
let unselectedColor = UIColor { traitCollection in
41+
switch traitCollection.userInterfaceStyle {
42+
case .dark:
43+
// Dark mode: slightly dimmed white (60% opacity for subtle difference)
44+
return UIColor.white.withAlphaComponent(0.6)
45+
default:
46+
// Light mode: slightly lighter dark color (60% opacity for subtle difference)
47+
return UIColor.black.withAlphaComponent(0.6)
48+
}
49+
}
50+
UITabBar.appearance().unselectedItemTintColor = unselectedColor
51+
52+
UITabBar.appearance().standardAppearance = appearance
53+
if #available(iOS 15.0, *) {
54+
UITabBar.appearance().scrollEdgeAppearance = appearance
55+
}
56+
}
57+
2758
// Create an intermediate binding that captures all tab selections
2859
// This is the proper SwiftUI way to detect same-tab taps without UIKit
2960
private var tabSelection: Binding<TabId> {

0 commit comments

Comments
 (0)