在所选标签栏项目上设置文本颜色 [英] Setting text-color on selected tab bar item

查看:132
本文介绍了在所选标签栏项目上设置文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个标签栏应用程序。我有四个标签;在选定的选项卡上,我需要为选项卡标题设置红色。我该怎么做?

I've created a tab bar application. I have four tabs; on the selected tab, I need to set the color red for tab title. How can i do that?

提前致谢。

推荐答案

如果我正确理解您的问题,您需要自定义 UITabBarItem 上的文本颜色。不幸的是,它真的不那么灵活。如果你打算这样做(除非你在专业人士的帮助下仔细考虑过这个设计,我建议反对!),你必须做一些非常可怕的事情才能让它发挥作用。

If I understand your question correctly, you want to customize the color of the text on the UITabBarItems. Unfortunately, it's really not that flexible. If you're intent on doing this (which, unless you've carefully considered the design with the help of a professional, I recommend against!), you'll have to do some really frightening things to get this to work.

我建议迭代 UITabBar 的子视图(根据需要多少级别),并寻找 UILabel 对象。如果你找到一些,你可以改变它们的颜色。如果不这样做,这意味着它的实现方式不同(可能在 -drawRect:方法中);如果情况确实如此,那么你真的应该放弃。

I'd suggest iterating through the subviews of the UITabBar (as many levels as necessary), and looking for UILabel objects. If you find some, you can change their color. If you don't, that means that it is implemented differently (probably in a -drawRect: method somewhere); if this happens to be the case, you really ought to give up.

祝你好运做任何事。

这篇关于在所选标签栏项目上设置文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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