tabbarController的tabBarItem设置图片有两个属性,分别是tabBarItem.image和tabBarItem.selectedImage。一个是选中时显示的图片,另一个是未选中时显示的图片。分别设置上即可。
detailViewController.tabBarItem.image = [notSelectedDetailImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
detailViewController.tabBarItem.selectedImage = [selectedDetailImge imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
如果这个 TabBarController 是从 storyboard 加载的,先写一个 UITabBarController 的子类,然后统一操作
for (UITabBarItem *item in self.tabBar.items) {
item.image = [item.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
item.selectedImage = [item.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}