1.push隐藏tabBar
//如果在push跳转时需要隐藏tabBar,设置self.hidesBottomBarWhenPushed=YES;
//并在push后设置self.hidesBottomBarWhenPushed=NO;
//这样back回来的时候,tabBar会恢复正常显示。
case 0:
{
ExperienceViewController *experienceVc = [[ExperienceViewController alloc]init];
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:experienceVc animated:YES];
self.hidesBottomBarWhenPushed = NO;
}
2.导航条左右按钮是系统图片或者自定义图片
{
//为导航栏添加左/右按钮,
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"Ic_more"] style:UIBarButtonItemStylePlain target:self action:@selector(btnNavLeft:)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(btnNavRight:)];
self.navigationItem.backBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];//设置返回无当前title或者“返回”汉字
self.navigationController.navigationBar.tintColor = [UIColor redColor];//返回按钮字体设置红色颜色
}
3.导航条背景颜色
{
self.view.backgroundColor = [UIColor whiteColor];
self.navigationController.navigationBar.barTintColor = [UIColor redColor];//导航条背景颜色
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];//导航条title字体和颜色
self.title = @"体验中心";
}
4.透明导航条
(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:YES];//pop页面
self.navigationController.navigationBar.tintColor = UIColorFromRGB(0x4f5154, 1.0);
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:UIColorFromRGB(0x4f5154, 1.0)}];//导航条title字体和颜色
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
}
(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];//当前页面
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];//返回按钮颜色
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];//导航条title字体和颜色
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];//设置导航栏为透明,原理就是不添加图片,但又不为空的UIImage给导航栏
[self.navigationController.navigationBar setShadowImage:[UIImage new]];//把导航栏上的分隔线用一个没有图片,但又不为空的UIImage给覆盖掉
}