Tab Bar Item - Selected / Unselected Icon

In Xcode 6, you now have the option to set the icon for the tab element for selected and unselected states. See 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 SELECTED states is not displayed. It just shows a space. Does anyone else have this problem? Below are the screenshots below:

REPORT tab is UNSELECTED

and

REPORT tab is SELECTED

Thanks!!!

+6
source share
2 answers

So, a way around this is:

  • Set the tab with the unselected default icon image that you want to use in the "BAR ITEM" section of the Attributes Inspector:

enter image description here

  1. Click on the Identity Inspector and in the DEFINED USER ATTRIBUTES section, click the + button to add a new value.

KEYPATH: selectedImage (IT SHOULD BE IT !!!)

TYPE: Image

VALUE: the name of the selected / highlighted icon image. I use Images.xcassets for my image objects.

enter image description here

Launch the app. You will notice that the image changes to the selected (and not just the highlighted version).

It works like a charm.

+3
source

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

  • Select tabItem.
  • Set the attribute "tintColor" with your color.

enter image description here

0
source

Source: https://habr.com/ru/post/978344/


All Articles