简体   繁体   English

标签栏项目图像不显示

[英]Tab Bar Item Image Does Not Show Up

I'm trying to assign a custom image to UITabBarItem in storyboard. 我正在尝试在故事板中为UITabBarItem分配自定义图像。 Unfortunately, it shows me an box instead of an image. 不幸的是,它显示了一个盒子而不是图像。

Here's my PNG image 这是我的PNG图像 在此输入图像描述

Storyboard: 故事板: 在此输入图像描述

How it appear in simulator: 它如何出现在模拟器中: 在此输入图像描述

As it turned out in order do display an actual image following code should be executed. 事实证明,为了显示实际的图像,应该执行以下代码。

[self.activityItem setImage:[[UIImage imageNamed:@"activity.png"] 
    imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

Note the Rendering Mode of UIImage. 注意UIImage的渲染模式。 You can find more about it UITabBar Reference Thanks to @ Vladislav Kovalyov 你可以找到更多关于它的信息UITabBar参考感谢@ Vladislav Kovalyov

Go to Assets folder. 转到Assets文件夹。 Select your tab image. 选择标签图片。 On the right side under Attributes you will find "Render As". 在属性下的右侧,您将找到“渲染为”。 Select "Original Image". 选择“原始图像”。

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

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