2

すべてのアプリのナビゲーションバーボタンの背景画像を変更しようとしています。appDelegateで実行する必要があると思います。

どうもありがとう

4

2 に答える 2

3

そのために外観プロキシを使用できます。これをappDelegateに追加するだけです

- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //...
    UIImage *myImage = [UIImage imageNamed:@"barButtonItemBackground.png"];
    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundImage:myImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    return YES;
}

詳細については、WWDC2011のセッション114を確認してください。

于 2012-05-07T10:53:16.183 に答える
1

ターゲットがiOS5の場合、次のコードをAppDelegateに配置できます。

float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version >= 5.0)
{
    // iPhone 5.0 code here
    UIImage *image = [UIImage imageNamed: @"image.png"];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

}
于 2012-05-07T10:52:20.170 に答える