self.navigationItem.title = @"navigationBar";
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
self.view.backgroundColor = [UIColor colorWithRed:0.064 green:0.522 blue:1.000 alpha:1.000];
然而 導航欄并沒有變成透明,好像被什么遮住了一樣,為什么呢?
我們用 Reveal 來分析一下視圖
navigationBar 上面有一個 ImageView 的子視圖,所有我們直接改變navigationBar的backgroundColor是沒有用的,
self.navigationItem.title = @"navigationBar";
self.view.backgroundColor = [UIColor colorWithRed:0.064 green:0.522 blue:1.000 alpha:1.000];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
//去除 navigationBar 底部的細線
self.navigationController.navigationBar.shadowImage = [UIImage new];
實現(xiàn)效果,導航欄透明