在iOS 11以前的好多導(dǎo)航欄透明方法不管用了,原因是11導(dǎo)航欄做了修改未斑,詳細(xì)說明請看大神文章,戳個鏈接:iOS NavigationBar 導(dǎo)航欄背景顏色設(shè)置 + iOS11 適配
在translucent屬性設(shè)置為NO之后會出現(xiàn)問題,把translucent設(shè)置為YES,之后加上代碼:
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
}
暫時感覺效果還好酝枢,應(yīng)該還可以優(yōu)化,等閑下來繼續(xù)研究一下悍手。