如何在iOS 7中将文本更改为自定义字体并使用自定义颜色

时间:2014-07-21 09:37:06

标签: objective-c ios7 uitabbar

How to change the unselected tabbaritem color in iOS7? 这不起作用。

我正在尝试这个

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:[ThemeManager customFont] size:10.0f],
                                                    NSForegroundColorAttributeName : [UIColor greenColor]
                                                    } forState:UIControlStateSelected];

颜色更改但不是我正在使用的自定义字体。

1 个答案:

答案 0 :(得分:1)

找到了解决方案。

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:[ThemeManager customFont] size:17.0f],
                                                    NSForegroundColorAttributeName: [UIColor greenColor]}
                                         forState:UIControlStateSelected];

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:[ThemeManager customFont] size:17.0f],
                                                    NSForegroundColorAttributeName: [UIColor blackColor]}
                                         forState:UIControlStateNormal];