1

現在、毎回ビューをプッシュする前に、以下のようなことをしなければなりません

    _homeNavigationController.navigationBar.barStyle = UIBarStyleBlack;
    _homeNavigationController.navigationBar.tintColor = nil;     

そして、パターン化された画像を使用して、色を別の色に設定したいと思います。

それで、それを行う簡単な方法はありますか?

4

2 に答える 2

3

iOS 5 を使用している場合は、appearance プロトコルを使用できます。

[[UINavigationBar appearance] setBackgroundImage:myImage];

ドキュメントは次の場所にあります。

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UINavigationBar_Class/Reference/UINavigationBar.html#//apple_ref/doc/uid/TP40006887

于 2012-05-17T23:07:07.707 に答える
1

カスタムの色合いの色(組み込み定数以外)を使用する場合は、次のコードを使用します。

これらをグローバルにどこかで定義します。

#define RGBCOLOR(r,g,b)         [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define COLOR_NAVBAR_TINT           RGBCOLOR(82, 154, 217)
#define COLOR_TOOLBAR_TINT          RGBCOLOR(82, 154, 217)

これをAppDelegate.mに追加し、アプリの初期化中に呼び出します。

- (void)initializeGlobalTheme {
    [[UINavigationBar appearance] setTintColor:COLOR_NAVBAR_TINT];
    [[UIToolbar appearance] setTintColor:COLOR_TOOLBAR_TINT];
}
于 2012-05-17T23:28:07.627 に答える