現在、複数のナビゲーション バーの色を持つ iPhone/iPad アプリに取り組んでいます。アプリの一部では、ナビゲーション バーはオレンジ色である必要があり、他の部分では紫色である必要があります。アプリのスタート画面では、ナビゲーション バーが非表示になっています。
ナビゲーション バー、戻るボタン、およびバー ボタンの色は、アプリの両方のセクションのセグエ識別子に従って、prepareForSegue で設定されます。
UIImage *navBackgroundImage = [UIImage imageNamed:@"Navigation-Bar-Orange.png"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
//Change the appearance of back button
UIImage *backButtonImage = [[UIImage imageNamed:@"Back-Orange"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 6)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
//Change the appearance of standard navigation button
UIImage *barButtonImage = [[UIImage imageNamed:@"Standard-Orange"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
[[UIBarButtonItem appearance] setBackgroundImage:barButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], UITextAttributeTextColor,
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8],UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Futura-CondensedMedium" size:21.0], UITextAttributeFont, nil]];
アプリケーションの他の部分に切り替える (再びセグエを通過する) 場合、ナビゲーション バーと標準バー ボタンは正しく色付けされますが、戻るボタンはアプリの前の部分の色になります。アプリケーション (viewWillAppear や viewDidLoad など) で何度か色を設定しようとしましたが、まだ問題が発生します。
この問題を解決し、アプリケーションの両方のセクションで正しいボタンの色を表示するにはどうすればよいですか? 異なるナビゲーション バーの色を設定する別の (より良い) 方法はありますか?
発生する問題の視覚的な例: