Tab Bar Item - Selected/Unselected icon

4.1k Views Asked by At

In Xcode 6, you now have the ability to set the icon for a tab item for its selected and unselected states. Please see the descriptions in the images below:

Selected Image - The image displayed when the tab bar item is selected.

and

Image - The image used to represent the item.

The only problem is that the image for the SELECTED states does not show. It just shows blank. Anyone else have this issue? Please see the screenshots below of the results:

REPORT tab is UNSELECTED

and

REPORT tab is SELECTED

Thanks!!!

2

There are 2 best solutions below

3
On BEST ANSWER

So the way to go around this:

  1. Set the tab with the default, unselected icon image you want to use in the "BAR ITEM" section in the Attributes Inspector:

enter image description here

  1. Click on the Identity Inspector, and under "USER DEFINED RUNTIME ATTRIBUTES," click the + to add a new value.

KEYPATH: selectedImage (IT HAS TO BE THIS!!!)

TYPE: Image

VALUE: The name of your selected/highlighted icon image. I use Images.xcassets for my image assets.

enter image description here

Run your app. You'll notice that the image changes to the selected (not just highlighted version of it.

Works like a charm.

0
On

I want to add some info about the colored tab icon. To change tab selection color:

  1. Select the tabItem.
  2. Set "tintColor" attribute with your prefer color.

enter image description here