tintColor 控制導航欄背景與按鈕顏色。barTintColor 專門控制背景色,tintColor 僅影響按鈕/標題文字。
UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
appearance.configureWithOpaqueBackground();
appearance.backgroundColor = [UIColor brownColor];
appearance.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
self.navigationController.navigationBar.standardAppearance = appearance;
self.navigationController.navigationBar.scrollEdgeAppearance = appearance;
iOS 7 引入扁平化設計,導航欄顏色 API 分離。舊專案維護需做版本判斷,新專案直接用 UINavigationBarAppearance 統一配置,支援深色模式、滾動邊緣效果等高級特性。