首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> C >> 關於C

iOS 導航欄顏色適配:iOS 6/7 版本差異處理

     編輯:關於C

版本差異

  • iOS 6 及之前:tintColor 控制導航欄背景與按鈕顏色。
  • iOS 7+:引入 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 統一配置,支援深色模式、滾動邊緣效果等高級特性。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved