#import "MyNavigationController.h"
@interface MyNavigationController ()
@end
@implementation MyNavigationController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
+(void)initialize
{
// 1.获得bar对象
UINavigationBar *navBar = [UINavigationBar appearance];
// 2.1.设置bar背景
// 设置导航栏背景图片
// [navBar setBackgroundImage:[UIImage imageNamed:@"viewBg"] forBarMetrics:UIBarMetricsDefault];
// 设置导航栏背景色
[navBar setBarTintColor:[UIColor colorWithRed:39/255.0 green:39/255.0 blue:39/255.0 alpha:1.0]];
// 设置导航栏左右bar button item的颜色
[navBar setTintColor:[UIColor whiteColor]];
// 设置导航栏中间标题的文字颜色
[navBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, nil]];
// 要保持默认的透明传统效果,需要设置下面2个方法
[navBar setTranslucent:YES];
[navBar setShadowImage:[[UIImage alloc] init]];
// 这个方法可以不写
[navBar setBackgroundColor:[UIColor clearColor]];
}
@end导航栏上文字颜色的设置
最新推荐文章于 2023-10-05 16:37:37 发布
4万+

被折叠的 条评论
为什么被折叠?



