2 回答

TA貢獻1824條經(jīng)驗 獲得超5個贊
ionic 中子控制器怎么調用父控制器
在iOS7下,默認導航欄背景,顏色是這樣的,接下來我們就進行自定義,如果你僅僅是更改一下背景和顏色,代碼會很簡單,不需要很復雜的自定義View來替代leftBarItem
更改導航欄的背景和文字Color
[objc] view plaincopy
//set NavigationBar 背景顏色&title 顏色
[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:213/255.0 alpha:1.0]];
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]];
效果如下:
我們把背景改成了藍色,title文字改成了白色,是不是很簡單呢?NavigationBar極其push過去的子頁面也會是你修改后的背景顏色

TA貢獻1828條經(jīng)驗 獲得超3個贊
方法二:
[objc] view plaincopy
//設置NavigationBar背景顏色
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
//@{}代表Dictionary
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
在導航欄使用背景圖片:
如果您的應用程序使用了自定義圖像作為欄的背景,你需要提供一個“更大”的圖片,使其延伸了狀態(tài)欄的后面。導航欄的高度現(xiàn)在是從44點(88像素)更改為64點(128像素)。
仍然可以使用了setBackgroundImage:方法來指定自定義圖像的導航欄。下面是代碼行設置背景圖片:
[objc] view plaincopy
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav_bg.png"] forBarMetrics:UIBarMetricsDefault];
- 2 回答
- 0 關注
- 895 瀏覽
添加回答
舉報