Introduction: In the project often hit the top of the homepage is infinite Carousel, need to rely on the top display. There are a number of ways to set the navigation bar to be transparent, and this can be done with a third party. Or simply brutally hide the navigation bar directly. But push to the next page when the navigation bar is needed, how to do it, Here are two ways to do this.
The first approach
-Be sure to hide the navigation bar in an animated way, so it works best when you use the swipe to return gestures, which is consistent with the motion diagram above. One drawback of this is that there is an animation of the navigation bar disappearing when switching tabbar.
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:YES];}- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES];}
The second approach
Set the self as the navigation Controller agent, implement the proxy method, set the navigation bar to hide and display in the controller to be displayed, using this method not only fits the sliding return gesture perfectly, but also solves the problem that the navigation bar dynamically hides when switching tabbar.
@interfaceWlhomepagecontroller () <Uinavigationcontrollerdelegate>@end@implementationWlhomepagecontroller#pragma mark-lifecycle-(void) Viewdidload {[Super Viewdidload];Set the agent for the navigation controller to selfself.navigationcontrollerself;} #pragma mark-uinavigationcontrollerdelegate// will show controller-(void) Navigationcontroller: ( Uinavigationcontroller *) Navigationcontroller Willshowviewcontroller: ( Uiviewcontroller *) Viewcontroller animated: (bool) animated { //determine if the controller to be displayed is itself bool isshowhomepage = [Viewcontroller Iskindofclass:[self class]]; [self.navigationcontroller Setnavigationbarhidden: Isshowhomepage animated:yes];}
Demo: Take a plane
The correct way to hide the iOS navigation bar "Go"