同時(shí)使用UINavigationController+UITabbarController,且能夠達(dá)到以下效果:
1、NavigationBar顏色無(wú)縫切換。
2、NavigationBar和TabBar無(wú)縫顯示和隱藏。
3、能夠自定義NavigationBar和TabBar。
1、顏色無(wú)縫切換
(1)在NavigationController中:
- (void)setUpNavbar{
? ? [self.navigationBar setTranslucent:NO];
? ? [self.navigationBar setShadowImage:[UIImage imageNamed:@"NavbarShadowClear.png"]];//圖像為透明圖像
}
(2)然后在各個(gè)頁(yè)面直接設(shè)置NavBar的顏色即可實(shí)現(xiàn)無(wú)縫切換
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
2、NavigationBar和TabBar無(wú)縫顯示和隱藏
(1)NavigationBar:
[self.navigationController setNavigationBarHidden:NO animated:YES];
[self.navigationController setNavigationBarHidden:YES animated:YES];
(2)TabBar(假設(shè)在控制器v1中要push一個(gè)控制器v2):
在v1需要push v2的地方
v2ViewController *v2 = [[v2ViewController alloc]init];
v2.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:v2 animated:YES];
3、自定義NavBar和TabBar
方法有很多,各舉一個(gè)簡(jiǎn)單的例子
NavBar使用customView
TabBar使用自定義UIView覆蓋到TabBar上面