Spiff
Spiff

Reputation: 45

Tab bar item icons are sizing very weird

So I don't know how this is happening at all. Ive tried everything remotely related to what might be happening, with no success. I have an initial view controller that presents a tab bar controller onto the screen. And any way I set the icons, which are all the same sizes 1* 2* and 3* wise, the right bar button is abnormally bigger than the other two!?

Heres what it looks like:

item sizing

class SceneScrollViewController: UITabBarController, UIScrollViewDelegate, UITabBarControllerDelegate {
     
    override func viewWillAppear(_ animated: Bool) {
           super.viewWillAppear(animated)
           delegate = self
           let exploreVC = Storyboard.explore.instantiateInitialViewController() as? UINavigationController
           let profileVC = Storyboard.profile.instantiateInitialViewController() as? UINavigationController
           let hubVC = Storyboard.hub.instantiateInitialViewController() as? UINavigationController
           profileVC.tabBarItem.image = UIImage.init(named: "profile")
           hubVC.tabBarItem.image = UIImage.init(named: "homeIcon")
           exploreVC.tabBarItem.image = UIImage.init(named: "tabBarSearch")
           viewControllers = [exploreVC, hubVC, profileVC]
           self.selectedIndex = 1
    }
}

If you have any idea what is happening please post them, anything helps. Also, the images are all proper size, and what's weirder: if I swap the search icon with profile ie, that same right buttonItem enlarges the search icon, and the profile icon sizes to the current search icon size below. SO no matter what image I set in right button slot, it sizes it weird.

Upvotes: 0

Views: 707

Answers (1)

Ketan Saini
Ketan Saini

Reputation: 82

Double-check your icon size, if still showing a larger icon then try to add insets to the tabBarItem.

profileVC.tabBarItem.imageInsets = UIEdgeInsets(top: -4, left: -4, bottom: -4, right: -4)

to make the size of all tabbar icons consistent you can give imageInsets to all tabs.

Upvotes: 0

Related Questions