123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //
- // NavigationBar.m
- // TCXF
- //
- // Created by 张毅成 on 2017/6/22.
- // Copyright © 2017年 张毅成. All rights reserved.
- //
- #import "NavigationBar.h"
- @implementation NavigationBar
- /**
- * 设置全局的导航栏背景图片
- *
- * @param globalImg 全局导航栏背景图片
- */
- + (void)setGlobalBackGroundImage: (UIImage *)globalImg {
- UINavigationBar *navBar = [UINavigationBar appearance];
- [navBar setBackgroundImage:globalImg forBarMetrics:UIBarMetricsDefault];
- }
- /**
- * 设置全局导航栏标题颜色
- *
- * @param globalTextColor 全局导航栏标题颜色
- */
- + (void)setGlobalTextColor: (UIColor *)globalTextColor andFontSize: (CGFloat)fontSize {
- if (globalTextColor == nil) {
- return;
- }
- if (fontSize < 6 || fontSize > 40) {
- fontSize = 16;
- }
- UINavigationBar *navBar = [UINavigationBar appearance];
- // 设置导航栏颜色
- NSDictionary *titleDic = @{
- NSForegroundColorAttributeName: globalTextColor,
- NSFontAttributeName: [UIFont systemFontOfSize:fontSize]
- };
- [navBar setTitleTextAttributes:titleDic];
- }
- @end
|