(注: SOにはいくつかの同様の質問がありますが、カスタムとシステムの両方のUITabBarItemsの選択されていない外観を変更したいという私の特定の問題には、どれも当てはまらないようです。)
私はiOS7で働いています。いくつかのボタンを持つ UITabBar があります。それらのいくつかは私のボタンであり、いくつかはシステムボタンです。例:
UITabBarItem *searchButton = [[UITabBarItem alloc] initWithTabBarSystemItem: UITabBarSystemItemSearch tag: navSearchItem];
UITabBarItem *bookMkButton = [[UITabBarItem alloc] initWithTabBarSystemItem: UITabBarSystemItemBookmarks tag: navBookmarksItem];
UITabBarItem *homeButton = [[UITabBarItem alloc] initWithTitle: @"Home" image: [self tabBarImageNamed: @"home-tab"] tag: navHomeItem];
UITabBarItem *setingButton = [[UITabBarItem alloc] initWithTitle: @"Settings" image: [self tabBarImageNamed: @"settings-tab"] tag: navSettingsItem];
navTabBar.items = @[ searchButton, homeButton, bookMkButton, setingButton];
選択したボタンの色合いは、次のように簡単に設定できます。
[[UITabBar appearance] setSelectedImageTintColor: MY_FAVORITE_COLOR];
選択されていないボタンのテキストの色を白に設定できます。
[[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, nil]
forState: UIControlStateNormal];
私がやりたいのは、UNSELECTEDボタンの画像の色合いを白に設定することです。選択されていない画像を簡単に設定できましたが、それは私のボタンでしか機能しません。システムボタンにもこれを行いたいです。つまり、検索とブックマークのボタンも選択されていない白にしたいのです。
カスタム ボタンを作成するためにアイコンを再作成しようとすると、Apple が文句を言うことは間違いありません。ドキュメントはかなり具体的で、Apple のアイコンにリモートで似たようなことをするべきではありません。
ヒント?
ありがとう!
編集: unselected=white が必要な理由は、私のデザインした背景に対して、デフォルトの灰色がアイコン/テキストを目に難しくするからです。