0

I want to change the default color of the tab bar item image to be the original color of the image (black) as opposed to a gray when it's not selected.

I also want to change the tab bar item image to a filled version once it's selected.

Last thing is the position.. It seems to expect text under it so it's not centered, how do I center it vertically and possibly make it smaller?

I'm currently setting it this way:

   let profileNavController = UINavigationController(rootViewController: profileController)
        profileNavController.tabBarItem.image = UIImage(named: "icon_tab_user")

This is how it looks selected and unselected: enter image description here enter image description here

Walker
  • 1,127
  • 15
  • 39

2 Answers2

0

From apple we know,

By default, the actual unselected and selected images are automatically created from the alpha values in the source images. To prevent system coloring, provide images with UIImageRenderingModeAlwaysOriginal.

Take a look here.
Changing tab bar item image and text color iOS

Community
  • 1
  • 1
Jamshed Alam
  • 12,424
  • 5
  • 26
  • 49
0

I was able to change the highlighted and unhighlighted images as well as the position with this:

let profileNavController = UINavigationController(rootViewController: profileController)
        let profileTabBarItem  = UITabBarItem(title: nil, image: UIImage(named: "icon_tab_user")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal), selectedImage: UIImage(named: "icon_tab_user_highlighted"))
        profileTabBarItem.imageInsets = UIEdgeInsetsMake(5.5, 0, -5.5, 0)
        profileNavController.tabBarItem = profileTabBarItem
Walker
  • 1,127
  • 15
  • 39