简体   繁体   English

iOS 8:界面构建器中设置的自定义选项卡栏项目的选定图像不起作用

[英]iOS 8: Selected image for custom tab bar item set in interface builder does not work

I have set in Storyboard tab bar item to be Custom, Image to my outline image and Selected image to my filled image but the selected image does not show up when I run the app. 我已将Storyboard选项卡栏项目设置为自定义,将图像设置为我的轮廓图像,将选定图像设置为我填充的图像,但是当我运行应用程序时,所选图像不会显示。

It works if I create a tab bar item programmatically using UITabBarItem(title: String?, image: UIImage?, selectedImage: UIImage?) 如果我使用UITabBarItem(title: String?, image: UIImage?, selectedImage: UIImage?)编程方式创建标签栏项目UITabBarItem(title: String?, image: UIImage?, selectedImage: UIImage?)

I use Xcode 6.1.1. 我使用Xcode 6.1.1。

What can be wrong? 有什么不对?

I think, it is a bug of Xcode, if you add a user defined runtime attribute with type Image and keyPath "selectedImage", you'll can set your image. 我认为,这是Xcode的一个错误,如果你添加一个用户定义的运行时属性,类型为Image和keyPath“selectedImage”,你可以设置你的图像。
Here example of the Tabbed Application template with a custom selected image on the second tab (I use a image from the first tab): 这里是选项卡应用程序模板的示例,在第二个选项卡上带有自定义选定图像(我使用第一个选项卡中的图像): 在此输入图像描述

This is more than likely because it doesn't meet the interface requirements. 这很可能是因为它不符合接口要求。 Tab bar items are picky, the strokes or outlines for a selected image have to be noticeably greater than its counterparts. 标签栏项目挑剔,所选图像的笔划或轮廓必须明显大于其对应项目。 See here specifically the notes about the stroke width. 有关行程宽度的说明,请参见此处 Conditionally, if it's not a 'filled' in variation of your unselected image it has a chance of not populating depending on you create the selected image in comparison. 有条件地,如果它不是未填充的未选择图像的变化,则根据您创建所选图像进行比较,它有可能不会填充。

As of Xcode 9, the functionality to set a selected image is available (and works) in interface builder. 从Xcode 9开始,设置所选图像的功能在界面构建器中可用(并且有效)。

在此输入图像描述

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

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