/**
* 第一次使用这个类的时候调用
*/
+ (void)initialize
{
//1.设置导航栏主题
[self setupNavBarTheme];
//2.设置导航栏按钮的主题
[self setupBarButtonItemTheme];
}
/**
* 设置导航栏按钮的主题
*/
+ (void)setupBarButtonItemTheme
{
UIBarButtonItem *item = [UIBarButtonItem appearance];
//设置背景
[item setBackgroundImage:[UIImage imageNamed:@"navigationbar_button_background"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[item setBackgroundImage:[UIImage imageNamed:@"navigationbar_button_background_pushed"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
//设置文字属性
NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
textAttrs[NSForegroundColorAttributeName] = [UIColor grayColor];
textAttrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:12];
[item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
[item setTitleTextAttributes:textAttrs forState:UIControlStateHighlighted];
}
设置导航栏按钮主题
最新推荐文章于 2021-04-15 16:18:44 发布