-1

I want to be able to click on my profile tab and change the image to a more bolder profile icon. I have two images. How can I change the picture when the user selects on a tab?

if selectedIndex == 3 {
            self.tabBarController?.tabBar.items?[3].image = UIImage(named: "AppIcon")
        }

This is in the tab bar view controller. I think this will only run once. I want to make it so it runs every time they click on it

NicolasElPapu
  • 1,612
  • 2
  • 11
  • 26
Captain Dilan
  • 71
  • 1
  • 6

1 Answers1

1

There is function you can use to detect selected tab in the UITabBarControllerDelegate

tabBarController(_ tabBarController: UITabBarController, 
                 didSelect viewController: UIViewController)
aiwiguna
  • 2,852
  • 2
  • 15
  • 26