すべてのアプリのナビゲーションバーボタンの背景画像を変更しようとしています。appDelegateで実行する必要があると思います。
どうもありがとう
そのために外観プロキシを使用できます。これを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を確認してください。
ターゲットが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];
}