简体   繁体   English

在xcode 6中设置选项卡栏选项图像

[英]Set tab bar item selected image in xcode 6

This is my setup for a tab bar item: 这是我对标签栏项目的设置:

在此输入图像描述

However when clicking on the item inside the app the 1051-id-badge-selected image is not shown, instead nothing is shown: 但是,当单击应用程序内的项目时,未显示1051-id-badge选择的图像,而是显示任何内容:

在此输入图像描述

Is something wrong with my setup? 我的设置有问题吗? Any ideas? 有任何想法吗?

To get around this issue and set selected image without writing any code, we can also use "User Defined Run Attributes". 要解决此问题并在不编写任何代码的情况下设置所选图像,我们还可以使用“用户定义的运行属性”。

在此输入图像描述

Select the tab bar item, then in 'Identity Inspector', add a new value from 'User Defined Runtime Attributes'. 选择选项卡栏项,然后在“Identity Inspector”中,从“用户定义的运行时属性”中添加新值。

Set the 'Key Path' to selectedImage , and choose 'Type' Image , then fill in the 'Value' with your image name. 将“Key Path”设置为selectedImage ,然后选择“Type” Image ,然后使用图像名称填写“Value”。


If the inspector solution is not working for you (eg because of an Xcode bug) you can try this solution. 如果检查员解决方案不适合您(例如,由于Xcode错误),您可以尝试此解决方案。 In AppDelegate: 在AppDelegate中:

var tabBarController = self.window!.rootViewController as UITabBarController
let tabItems = tabBarController.tabBar.items as [UITabBarItem]

tabItems[2].selectedImage = UIImage(named: "1051-id-badge-selected.png")

Update on May 25, 2016: 2016年5月25日更新:

On Xcode 7.3.1 the Selected Image field under Tab Bar Item section is working correctly. 在Xcode 7.3.1上, Selected Image Tab Bar Item部分下的“ Selected Image字段正常工作。 (But I don't know from which exact version Apple fixed it for Xcode). (但我不知道Apple为Xcode修正了哪个版本)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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