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 rough directly hide the navigation bar. But push to the next page when the navigation bar is needed, how to do, here are two ways.
- 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.
@interface Wlhomepagecontroller () <UINavigationControllerDelegate> @end @implementation Wlhomepagecontroller # pragma mark-lifecycle-(void) viewdidload { [super viewdidload]; Set the proxy for the navigation controller to self self.navigationController.delegate = self;} #pragma mark-uinavigationcontrollerdelegate//will display Controller-(void) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller Willshowviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) Animated { // Determine if the controller you want to display is your own BOOL isshowhomepage = [Viewcontroller iskindofclass:[self class]]; [Self.navigationcontroller setnavigationbarhidden:isshowhomepage animated:yes];}
How to hide the iOS navigation bar correctly