ナビゲーション コントローラーをサブクラス化して、NavigationBar をカスタマイズしようとしています。何らかの理由で、カスタム ボタンが表示されません。私のセットアップは非常に簡単です。カスタム サブクラスNavControllerを使用する Navigation Controller に埋め込まれた ViewController があります。
@interface NavController ()
@end
@implementation NavController
- (void)viewDidLoad{
[super viewDidLoad];
UIImage *wlImage = [UIImage imageNamed:@"wl-icon.png"];
UIButton *wlButton = [UIButton buttonWithType:UIButtonTypeCustom];
[wlButton setFrame:CGRectMake(0, 0, wlImage.size.width, wlImage.size.height)];
[wlButton setBackgroundImage:wlImage forState:UIControlStateNormal];
UIBarButtonItem *wlButtonItem = [[UIBarButtonItem alloc] initWithCustomView:wlButton];
wlButtonItem.tintColor = [UIColor blackColor];
self.navigationItem.rightBarButtonItem = wlButtonItem;
self.navigationBar.tintColor = [UIColor blackColor];
}
@end
アプリをテストしようとすると、機能しているように見える唯一のカスタマイズは色合いです。ボタンは表示されません。
ナビゲーション項目と関係があるのだろうかと思っています。
初期ビュー コントローラーが独自のデフォルト設定内でナビゲーション項目をオーバーライドしている可能性がありますか?