解决方法
– (void)setFinishedSelected
Image:withFinishedUnselectedImage:不推荐使用.如果您使用的是故事板,那就很简单了
UITabBarItem *tabBarItem0 = [self.tabBar.items objectAtIndex:0]; UIImage* selectedImage = [[UIImage imageNamed:@"settings-active"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; tabBarItem0.selectedImage = selectedImage;
编辑
在Swift中:
var settingsItem = self.tabBar.items?[0] as UITabBarItem settingsItem.selectedImage = UIImage(named: "home-selected")
请注意,此代码属于UITabBarController子类的viewDidLoad重写.