iOS Hide Navigation Bar and Status Bar Implementation

  • 2021-06-29 12:10:55
  • OfStack

iOS Hide Navigation Bar and Status Bar Implementation

The height of the status bar is 20 and the height of the navigation bar is 44. If there are also status bar navigation bars, we usually set the position of the control on view to X greater than or equal to 64.

1: Hide navigation bar: self.navigationController.navigationBarHidden = YES;

2: Hide the status bar:

Step 1: Add two types (Type) to the info.plist file as the bool option, Status bar is initially hidden as the YES option;View controller-based status bar appearance is set to NO;

Step 2: Write the code on the page where you want to hide the status bar: [UIApplication sharedApplication]. statusBarHidden = YES;

In addition, it is worth mentioning that the principle and nature of hiding the status bar and navigation bar are the same. On one page, A hides the status bar/navigation bar. On other pages related to B, such as Apush to B, it also hides the status bar/navigation bar. If you do not want to hide the status bar/navigation bar of a page,You can write [UIApplication sharedApplication].statusBarHidden = NO/self.navigationController.navigationBarHidden = NO in viewWillAppear:(BOOL)animated;

Thank you for reading, I hope to help you, thank you for your support on this site!


Related articles: