首页 > 技术文章 > UITabBar 设置字体的颜色(选中状态/正常状态)setTitleTextAttributes

lrr0618 2016-02-20 12:58 原文

UITabbar有个setTintColor这个方法,可以理解为,高亮的时候,或者点击后的颜色设置。


UITabBarItem有个setTitleTextAttributes的方法,是用来设置字体的颜色。

 

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:

                                                       [UIColor redColor], NSForegroundColorAttributeName,

                                                       nil] forState:UIControlStateNormal];

    UIColor *titleHighlightedColor = [UIColor greenColor];

    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:

                                                       titleHighlightedColor, NSForegroundColorAttributeName,

                                                       nil] forState:UIControlStateSelected];

推荐阅读