UINavigationController
-
navigationBar有一個 translucent屬性.默認是YES.如果標簽欄有一個自定義背景圖片,如果系統(tǒng)判定圖片像素值α<1.0,系統(tǒng)將應用透明度低于1.0的形象. 也就是translucent = YES;
當 translucent = YES時,圖層是這樣的 view的fream從屏幕上方開始,能透過導航條看到后面view顏色
Snip20161113_21.png -
當 translucent =NO時,圖層是這樣的 view的fream從導航條下方,不能透過導航條看到后面view顏色
Snip20161113_20.png
導航欄樣式
- 如果有導航控制器時,導航欄的樣式的權限是默認交給導航控制器做全局處理
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- 如果實現(xiàn)了下面的方法,導航控制器就把權限交給處于棧頂?shù)目刂破鱽碓O置導航條的樣式,必須實現(xiàn)此方法
- (UIViewController *)childViewControllerForStatusBarStyle {
return self.topViewController; // 返回當前的棧頂控制器
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleDefault;
}
隱藏導航欄
- 隱藏導航欄導航控制器不能操作,只能去沒個子控制器去設置,官方不建議隱藏
- (BOOL)prefersStatusBarHidden {
return YES;
}
隱藏tabBar
- 控制器跳轉的時候,我們需要隱藏導航控制器的非根控制器的tabBar
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
//tabBar會在創(chuàng)建之前就被隱藏,所以需要判斷.
if (self.childViewControllers.count > 0) {
viewController.hidesBottomBarWhenPushed = YES;
}
[super pushViewController:viewController animated:animated];
}
去掉導航條下面的陰影線
- 把導航條下面的隱影線去掉,圖片參數(shù)不能傳"nil"把導航條徹底透明去掉陰影線
[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
// 清空陰影圖片
[self.navigationBar setShadowImage:[UIImage new]];
常用的屬性
- 如果要設置內容全找item
- 如果要改的是顏色及文字屬性相關的找bar
// 設置導航條內容主題色
self.navigationBar.tintColor = [UIColor whiteColor];
// 設置導航條及狀態(tài)欄的背景色
self.navigationBar.barTintColor = [UIColor blueColor];
//常用的設置導航條標題文字顏色及字體大小的作法
self.navigationBar.titleTextAttributes = @{NSFontAttributeName : [UIFont systemFontOfSize:17], NSForegroundColorAttributeName : [UIColor whiteColor]};
UITabBarController
- UITabBar也有translucent屬性 道理和上面一樣 只是是否顯示標簽欄后面的view
- 不渲染taBbar上的圖片
vc.tabBarItem.selectedImage = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
或者找到圖片這樣改

BCFEE316-AF56-4B40-8957-9D8C03676127.png

