I updated my code to the following and it works now. I fixed the problem by using imageWithRenderingMode
.
//This is the line that I updated
myController.tabBarItem.image = [[UIImage imageNamed:@"someImage.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
//And added this line too, I used the same original image not new one for the selected case
myController.tabBarItem.selectedImage = [UIImage imageNamed:@"someImage.png"];
//The rest of code is the same
UPDATE
For case of more than one barItem, define navigation controllers as following:
UINavigationController* firstNavigationController;
UINavigationController* secondNavigationController;
UINavigationController* thirdNavigationController;
firstNavigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
firstNavigationController.tabBarItem.image = [[UIImage imageNamed:@"someImage1.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
secondNavigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
secondNavigationController.tabBarItem.image = [[UIImage imageNamed:@"someImage2.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
thirdNavigationController = [[UINavigationController alloc] initWithRootViewController:thirdViewController];
thirdNavigationController.tabBarItem.image = [[UIImage imageNamed:@"someImage3.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];