在UITabBarItem中更改字体 [英] Changing font in UITabBarItem

查看:185
本文介绍了在UITabBarItem中更改字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码,它不起作用,我做错了什么?

Hi I have this code and it doesn't work, what am I doing wrong?

- (void)viewDidLoad
{    
    [self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont, nil] forState:UIControlStateDisabled];
}

BTW这不是我viewDidLoad中唯一的东西,但我只是想告诉你伙计们,我把它放在那里。

BTW that's not the only thing in my viewDidLoad but I just wanted to show you guys thats where I put it.

推荐答案

按照:如何更改iOS 5中UITabBarItem中文本的颜色

看起来解决方案可能是将消息发送到外观代理,而不是一个项目:

It looks like the solution may be sending the message to the appearance proxy, instead of one item:

(在iOS 7.0 +中不推荐使用)

[[UITabBarItem appearance] setTitleTextAttributes:@{UITextAttributeFont: [UIFont fontWithName:@"AmericanTypewriter" size:20.0f]} forState:UIControlStateNormal];

对于iOS 7.0+使用:

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"AmericanTypewriter" size:20.0f]} forState:UIControlStateNormal];

这篇关于在UITabBarItem中更改字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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