Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Tab bar item icons appear darker

When setting the icons for the tab bar items it seems that the icons are appearing darker for some reason. It seems like its using the default tints for the selected and not selected states of the icons. Even though the color of the images are correct.

For information here is the link to the question on stack overflow.

http://stackoverflow.com/questions/33861411/tab-bar-item-icons-appear-darker

1 Answer

Martin Wildfeuer
PLUS
Martin Wildfeuer
Courses Plus Student 11,071 Points

I can see that you already got an answer on stackoverflow, so just let me sum it up here quickly.

The Apple Documentation says the following on UITabBarItem:

By default, the actual selected image is automatically created from the alpha values in the source image. To prevent system coloring, provide images with UIImageRenderingModeAlwaysOriginal.

That is, colors provided in the images are ignored by default when set on an UITabBarItem, but rather system defaults are applied. To ensure images are displayed like you intended them to be, provide a standard and selected icon as in the following example:

...
myTab.image = [[UIImage imageNamed:@"iconStandard.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
myTab.selectedImage = [[UIImage imageNamed:@"iconSelected.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
...

Also worth a read: The iOS Human Interface Guidelines on tab bar icons.

Cheers for explaining and clearing that up mate!