// statusBar样式
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
// 字体明暗
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlack];
// 半透明
self.navigationController.navigationBar.translucent = YES;
// 填充颜色
self.navigationController.navigationBar.barTintColor = …;
// 自定义barButtonItem
第一种:
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:img style:UIBarButtonItemStylePlain target:self action:@selector(method)];
第二种(推荐):
UIButton *button = [[UIButtonalloc]initWithFrame:CGRectMake(0,0,50,25)];
[button addTarget:self action:@selector(method) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.rightBarButtonItem = item;
// 导航栏返回图标只显示图标不显示文字
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-SCREEN_WIDTH, -SCREEN_HEIGHT)forBarMetrics:UIBarMetricsDefault];
// 设置导航栏透明
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
// 去掉导航栏底部黑线
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
// 设置侧滑手势
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
// 自定义导航栏颜色及字体
[[UINavigationBar appearance] setBarTintColor:UIColorFromHex(Main_Color)]; // 导航栏颜色
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; // 文字颜色
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:FontSize18 weight:UIFontWeightMedium]}]; // 字体样式
[[UINavigationBar appearance] setTranslucent:NO]; // 不透明