[英]how to change backbutton color iOS7
我已經為iOS7開發了一款具有這種設計的應用程序
你可以看到我的所有BackButton都有一個藍色箭頭(使用UINavigationController和segues),我想把它們變成紅色,這是我的代碼:
[UIBarButtonItem appearance]setTintColor:(UIColorFromRGB(toolbarTintColor))];
[[UIBarButtonItem appearance]setTitleTextAttributes:textAtributesDictionaryNavBarButtons forState:UIControlStateNormal];
但結果只適用於所有其他按鈕,任何幫助,我會很感激
在此先感謝您的支持
導航欄的色調屬性確定iOS 7中其條形按鈕項的文本顏色。您要查找的代碼如下所示:
[[UINavigationBar appearance] setTintColor:[UIColor redColor]];
當然,用你想要的任何顏色替換[UIColor redColor]
。
將此代碼放入App Delegate中:
Objective-C的
[self.window setTintColor:[UIColor redColor]];
迅速
self.window?.tintColor = UIColor.redColor()
如果您不想更改整個應用程序中的色調顏色,只想在一個導航欄上執行此操作,請執行以下操作:
self.navigationController.navigationBar.tintColor = [UIColor redColor];
如果你想要swift版本。
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
此外,如果要將此樣式應用於所有導航視圖控制器。 將該代碼放在AppDelegate中的應用程序didFinishLaunchingWithOptions方法中
迅速:
self.navigationController?.navigationBar.tintColor = UIColor.grayColor()
-(void)viewDidAppear:(BOOL)animated
{
//set back button color
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
//set back button arrow color
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.