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給覆蓋掉
}