我们项目里面一般会用一个公用的导航栏,但是有时候我们在某个控制里面的导航栏,不想用公用的颜色背景,比如这里我们需要透明的背景
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; for (UIView *aView in self.navigationController.navigationBar.subviews) { if ([aView isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]) { aView.hidden = YES; } } } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; for (UIView *aView in self.navigationController.navigationBar.subviews) { if ([aView isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")]) { aView.hidden = NO; } } }
viewWillAppear是弄透明 viewWillDisappear是为了离开该控制器还原为公用的导航栏
转载于:https://www.cnblogs.com/yulongjiayuan/p/5407507.html
相关资源:新旺铺导航条背景色透明代码