简体   繁体   English

iOS更改标签栏图标颜色

[英]iOS change Tab Bar Icon Color

I was under the impression that the way to create tab bar icons is to create the icons with the appropriate transparency (after reading this http://greenerpastures.dk/blog/iphone-udvikling/how-to-make-tab-bar-icons ). 我的印象是,创建标签栏图标的方法是创建具有适当透明度的图标(阅读此http://greenerpastures.dk/blog/iphone-udvikling/how-to-make-tab-bar-图标 )。 I've changed my tab bar to be gray so my icon is in the range of gray to white depending on the transparency. 我将标签栏更改为灰色,因此图标的透明度取决于透明度,介于灰色到白色之间。 Here's and image with no transparency in the icon image: 这是图标图片中不透明的图片:

在此处输入图片说明

And here's one with quite a bit of transparency in the icon image: 这是图标图像中具有相当透明度的一个:

在此处输入图片说明

My question is, how can I make it so my icon is black while keeping my tab bar as gray? 我的问题是,如何使它的图标为黑色,同时保持选项卡栏为灰色? Should I just use a regular image and forget the transparent icons? 我应该只使用常规图像而忘记透明图标吗? Is it bad practice to use non-transparent images? 使用非透明图像是不好的做法吗?

I figured it out. 我想到了。 I just had to set the background color in photoshop to the color I wanted. 我只需要在photoshop中将背景色设置为所需的颜色即可。

用这个

[self.tabBarController.tabBar setSelectedImageTintColor:TAB_BAR_SELECTED_TAB_COLOR];

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

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