When using Uitabbarcontroller in a project, each uitabbaritem can display the corresponding picture.
The Uitabbaritem has two states, that is, the selected/unchecked state.
If you set the picture with storyboard, the picture is set to the selected state, and it is automatically populated with dark blue. (that is, default color), which is automatically grayed out when unchecked.
This greatly affects the aesthetics.
As follows:
We want the effect that should be like this:
If this is to happen, add the following code to the Uitabbarcontroller:
Nsarray *items = self.tabBar.items; Uitabbaritem *homeitem = items[0]; Homeitem.image = [[UIImage imagenamed:@ "Tab_buddy_nor.png"] Imagewithrenderingmode: Uiimagerenderingmodealwaysoriginal]; Homeitem.selectedimage = [[UIImage imagenamed:@ "Tab_buddy_press.png"] Imagewithrenderingmode: Uiimagerenderingmodealwaysoriginal]; Uitabbaritem *qqitem = items[1]; Qqitem.image = [[UIImage imagenamed:@ "Tab_me_nor.png"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; Qqitem.selectedimage = [[UIImage imagenamed:@ "Tab_me_press.png"] Imagewithrenderingmode: Uiimagerenderingmodealwaysoriginal];
iOS Development-Uitabbaritem custom picture (black removal)