简体   繁体   中英

Tab Bar Item - Selected/Unselected icon

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:

选定图像 - 选择标签栏项目时显示的图像。

and

图像 - 用于表示项目的图像。

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选项卡是UNSELECTED

and

REPORT选项卡是SELECTED

Thanks!!!

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:

在此输入图像描述

  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.

在此输入图像描述

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

Works like a charm.

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.

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM