0

私の目標は、ナビゲーション項目の右側にボタンを追加することです。問題は、私の UINavigationItem の tintColor は濃い灰色ですが、ボタン (UIBarButtonSystemItemAdd) を灰色ではなく白にしたいということです。

読んだ後、これを達成するために白の独自のカスタム画像を作成する必要があるようです。これを実行しました。次のコードで設定しています。

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] 
                             initWithImage:[UIImage imageNamed:@"CustomAddButton.png"]                                                                   
                                                         style:UIBarButtonItemStylePlain
                                                        target:self
                                                        action:@selector(addNewItem)];
self.navigationItem.rightBarButtonItem = addButton;

ここで、CustomAddButton@2x.png は 40x40 の画像で、アルファ レイヤーと白いプラスのみがあります。画像が白く表示される代わりに、それが含まれているナビゲーション項目の tintColor よりもわずかに明るい灰色です。カスタム画像を作成せずに UIBarButtonSystemItemAdd を白く表示する方法はありますか? そうでない場合、私は何を間違っていますか?

ありがとう!

4

1 に答える 1