2

iOS 7 のガイドラインを満たすようにアプリをアップグレードしています。メインのタブ バー コントローラーの背景は青色で、デフォルトの灰色の「選択されていない」色合いにより、アイコンがほとんど見えなくなります。これらのアイコンの色合いを変更するにはどうすればよいですか? 黒か、青の背景とはかなり対照的なものにしたいと思います。

window.TintColor = White を使用してアプリ全体の色合いを既に構成しましたが、選択した色のみが変更されます。(TabBar.TintColor と同じ)

4

1 に答える 1

3

私はそれをテストしていませんが、この答えは残念ながら唯一の解決策のようです https://stackoverflow.com/a/18433996/1732987

更新: 後世のためにコードをコピーしました。

// set color of selected icons and text to red
self.tabBar.tintColor = [UIColor redColor];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor], UITextAttributeTextColor, nil] forState:UIControlStateSelected];


// set color of unselected text to green
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor greenColor], UITextAttributeTextColor, nil]
                                     forState:UIControlStateNormal];

// set selected and unselected icons
UITabBarItem *item0 = [self.tabBar.items objectAtIndex:0];

// this way, the icon gets rendered as it is (thus, it needs to be green in this example)
item0.image = [[UIImage imageNamed:@"unselected-icon.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

// this icon is used for selected tab and it will get tinted as defined in self.tabBar.tintColor
item0.selectedImage = [UIImage imageNamed:@"selected-icon.png"];
于 2013-09-21T15:44:20.320 に答える