Alexander Khitev
Alexander Khitev

Reputation: 6851

TabBar icon becoming a rectangle when its state is selected

I use two icons for different states tabBarItem.

My problem is that when tabbar is selected one icon to become a rectangle.
I did the other icons, and they appear well. I was looking for any information not found on this topic. How can I fix it?
enter image description here

My code

   override func viewDidLoad() {
    super.viewDidLoad()
    let triviaMainTableViewController = StoryboardManager.triviaStoryboard.instantiateViewControllerWithIdentifier("TriviaMainTableViewController") as! TriviaMainTableViewController
    viewControllers = [triviaMainTableViewController]

    tabBarItem.image = UIImage(named: "TriviaTabBarDefault")?.imageWithRenderingMode(.AlwaysOriginal)
    tabBarItem.selectedImage = UIImage(named: "TriviaTabBarSelected")
    tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3)

    navigationBar.barTintColor = ColorManager.greenColor
}

Upvotes: 0

Views: 108

Answers (1)

Paulw11
Paulw11

Reputation: 114836

You need to make sure you have put your icon on a transparent background in order for the selection highlight to work correctly. If the background color of the image isn't transparent it may look fine when it is not selected, but not when it is selected.

Upvotes: 1

Related Questions