在xcode 6中设置选项卡栏选项图像 [英] Set tab bar item selected image in xcode 6

查看:97
本文介绍了在xcode 6中设置选项卡栏选项图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我对标签栏项目的设置:

This is my setup for a tab bar item:

但是,当点击应用程序内的项目时,未显示1051-id-badge选择的图像,而是显示任何内容:

However when clicking on the item inside the app the 1051-id-badge-selected image is not shown, instead nothing is shown:

我的设置有问题吗?任何想法?

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".

选择标签栏项,然后在Identity Inspector中,从用户定义的运行时属性中添加新值。

Select the tab bar item, then in 'Identity Inspector', add a new value from 'User Defined Runtime Attributes'.

将'Key Path'设置为 selectedImage ,然后选择'Type' Image ,然后填写'值'与您的图像名称。

Set the 'Key Path' to selectedImage, and choose 'Type' Image, then fill in the 'Value' with your image name.

如果检查员解决方案不适合您(例如由于Xcode错误)你可以尝试这个解决方案。在AppDelegate中:

If the inspector solution is not working for you (e.g. because of an Xcode bug) you can try this solution. In 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")

2016年5月25日更新:

Update on May 25, 2016:

在Xcode 7.3.1上所选图像 标签栏项目部分下的字段工作正常。 (但我不知道Apple为Xcode修正了哪个版本)。

On Xcode 7.3.1 the Selected Image field under Tab Bar Item section is working correctly. (But I don't know from which exact version Apple fixed it for Xcode).

这篇关于在xcode 6中设置选项卡栏选项图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆