Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTunde Adegoroye
20,597 PointsTab 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
Courses Plus Student 11,071 PointsI 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.
Tunde Adegoroye
20,597 PointsTunde Adegoroye
20,597 PointsCheers for explaining and clearing that up mate!
Martin Wildfeuer
Courses Plus Student 11,071 PointsMartin Wildfeuer
Courses Plus Student 11,071 PointsSure thing! :)