In my app, one of the TabBar Items needs a custom icon, depending on context within the app.
I'm using this code to accomplish that:
item1 = [[UITabBarItem alloc] initWithTitle:@"Jij" image:inactiveIcon selectedImage:activeIcon];
and that works just fine. As long as I don't set an icon in the Storyboard.
In my experiments, I found out that running above code from the
didFinishLaunchingWithOptions executes the code before the
TabBar even exists. At least that is what I think.
So, in order to have at least a temporary placeholder icon, I have to set it in the Storyboard. But somehow, that keeps my code from updating the image.
I even looked into subclassing the
TabBarController, just to make sure that the icon is loaded in time.
Please point me at the mistakes in my code, logic or findings.
To summarize the question:
How come I cannot change an
TabBarItem image once it is set in the Storyboard?
You can also set the property Render As of your tab bar images within your asset catalog directly.
There you have the option to set the property to Default, Original Image and Template Image. Hope this will help :)