Search code examples
iosswiftuitabbaruitabbaritem

UITabBarItem - All items displays the selectedImage on first launch


I have a UITabBar with 4 UITabBarItems and each item have an image and a selectedimage.

Normally I want to have that :

enter image description here

But on first launch, the app displays all selected images :

enter image description here

Then, if I kill the app, I have the good state (first image). Why ?

EDIT :

This is a screen of my interface builder : enter image description here


Solution

  • I found the problem. There were this lines in the code and they make a conflict :

    for item in tabBarController.tabBar.items! {
       item.image = item.selectedImage?.imageWithColor(tintColor: UIColor(hex: "#777777")).withRenderingMode(.alwaysOriginal)
    }
    

    I just deleted them and it worked.