How to hide the status bar in a iOS App using Swift?

Sometimes in our application, we need to hide the status bar, navigation bar, and other things and only show the content we want to display. In this article, we’ll see how to hide the status bar in our application. To hide status bar in our iOS application using swift language we need to go through very basic steps.

We can hide the status bar in two general ways. Both of these methods involve a common step.

Common Step

  • Go to Your info.plist file.
  • Add a key called “View controller-based status bar appearance” and set its value to NO.

This was a common step we’ll use in both the methods mentioned below, which include one more step.

Method 1

In your info.plist file itself, add another key called “Status bar is initially hidden” and set it to YES.

Method 2

  • Go to your app delegate file.
  • Inside the method app did finish launching add a line of code.
UIApplication.shared.isStatusBarHidden = true

This will hide the status bar throughout the application.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
   // Override point for customization after application launch.
   // UIApplication.shared.isStatusBarHidden = true
   return true

Both the above methods produce the same result which is,

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 30-Jul-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started