- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]forBarMetrics:UIBarMetricsDefault];
//去掉导航栏底部的黑线
self.navigationController.navigationBar.shadowImage = [UIImage new];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
}
//给导航条设置一个空的背景图 使其透明化
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
//去除导航条透明后导航条下的黑线
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
//全局设置
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// 2.滑动返回手势
self.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
//修改返回按钮的颜色
self.navigationBar.tintColor = [UIColor orangeColor];
//导航控制器标题的颜色
// [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]}];
self.navigationBar.translucent = NO;
// 去除导航条底部线
[[UINavigationBar appearance] setBackgroundImage:[self createImageWithColor:[UIColor orangeColor]] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[self createImageWithColor:[UIColor blueColor]]];
//[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
//forBarMetrics:UIBarMetricsDefault]
//self.navigationBar.topItem.title = @"";
// [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, 0) forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setTitleTextAttributes:
@{NSFontAttributeName:[UIFont systemFontOfSize:20],
NSForegroundColorAttributeName:[UIColor greenColor]}];
}