0

I have 5 different tabs on my tabbar and only 2/5 tabbar images show up, even though I downloaded them from the same source.

I tried setting the rendering mode to always original

func setupTabBar() {

    let homeController = UINavigationController(rootViewController: HomeViewController())
    homeController.tabBarItem.image = UIImage(named: "menu_green")?.withRenderingMode(.alwaysOriginal)
    homeController.tabBarItem.selectedImage = UIImage(named: "menu_lightgreen")?.withRenderingMode(.alwaysOriginal)

    let statsController = UINavigationController(rootViewController: StatsViewController())
    statsController.tabBarItem.image = UIImage(named: "stats_green")?.withRenderingMode(.alwaysOriginal)
    statsController.tabBarItem.selectedImage = UIImage(named: "stats_lightgreen")?.withRenderingMode(.alwaysOriginal)

    let addController = UINavigationController(rootViewController: AddViewController())
    addController.tabBarItem.image = UIImage(named: "add_green")?.withRenderingMode(.alwaysOriginal)
    addController.tabBarItem.selectedImage = UIImage(named: "add_lightgreen")?.withRenderingMode(.alwaysOriginal)

    let shopController = UINavigationController(rootViewController: ShopViewController())
    shopController.tabBarItem.image = UIImage(named: "shop_green")?.withRenderingMode(.alwaysOriginal)
    shopController.tabBarItem.selectedImage = UIImage(named: "shop_lightgreen")?.withRenderingMode(.alwaysOriginal)

    let userController = UINavigationController(rootViewController: ProfileViewController())
    userController.tabBarItem.image = UIImage(named: "user_green")?.withRenderingMode(.alwaysOriginal)
    userController.tabBarItem.selectedImage = UIImage(named: "user_lightgreen")?.withRenderingMode(.alwaysOriginal)

    viewControllers = [homeController, statsController, addController, shopController, userController]

    guard let items = tabBar.items else {
        return

}
theMikeSwan
  • 4,739
  • 2
  • 31
  • 44
Michiel.T
  • 11
  • 1
  • make sure all the used images are present in assets. – bestiosdeveloper Aug 30 '19 at 13:25
  • Split the image creation and assignment into two lines so that the first line creates the image and the second line sets it as the tab bar item's image. Then add a breakpoint to the line that creates the first image and make sure that each image has an actual value in it. You may have misspelled one of the names or forgotten at add an image. – theMikeSwan Aug 30 '19 at 13:29
  • haven't forgotten to add any images, they are all present in my assets folder and I didn't misspell any names in my code – Michiel.T Aug 30 '19 at 15:54

0 Answers0