如何在标签栏中设置图像而不是在ios中设置色彩? [英] How to set Image in Tabbar not Tint color in ios?

查看:125
本文介绍了如何在标签栏中设置图像而不是在ios中设置色彩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 UITabbar 的应用程序,我想在Tabbar中设置图像,但无法在Tabbar中设置图像。而不是因为它是图像我得到色彩的图像形状,是否可以像在Tabbar中设置图像? 。

I have an application with UITabbar , I want to set image in Tabbar but am unable to set image in Tabbar. Instead of as it is image i get image shape in tint color, Is it possible to set image as it is in Tabbar? .

我已尝试此代码但无法设置图像。

i have Tried this code but Unable to set image.

UITabBar *tabBar = self.tabBar;

UITabBarItem *targetTabBarItem = [[tabbar items] objectAtIndex:0]; // whichever tab-item
UIImage *selectedIcon = [UIImage imageNamed:@"name-of-selected-image.png"];
[targetTabBarItem setSelectedImage:selectedIcon];


推荐答案

您需要设置图像属性属性渲染为原始图像。要更改此选项,请从资源中选择您的图像,然后在属性检查器中渲染为属性设置为原始图片是这样的。

You need to set your image attributes property Render As to Original Image. To change this select your image from assets and in the Attributes Inspector set Render As property to Original Image like this.

这篇关于如何在标签栏中设置图像而不是在ios中设置色彩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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