Learn iOS UI status bar in simple language
in this part; Using an example; We get acquainted with the ui toolbar on iOS; Also with this example we learn how to show or hide the iOS status bar in swift apps using xcode.
IOS UI status bar
In iOS, the status bar is used to display useful information about the device; For example, battery level, weak network; Time and other information are displayed. In general, the status bar on iOS devices is displayed at the top of the screen as shown below.
To hold the status bar steady; Generally in the system; It is always recommended to use a system with a status bar; Be provided in advance; Not to use a system that has a custom status bar on your iOS device. We can now change the display bar style to light or dark; We can also temporarily hide the status bar using the full-screen option.
Now, with an example, we see how to hide the status bar of our Swift applications.
Create iOS toolbar app in Swift
To create a new project in Xcode on iOS, open Xcode from the application folder list. After opening Xcode, the welcome window will open as shown below. In the Welcome window, click on the second option, “Create a new Xcode Project”; Click (create a new Xcode Project) or select the File New Project path.
After selecting “Create a new Xcode project”, a new window will open in which we must select our template.
The new Xcode window includes several built-in application templates to implement the usual type of iOS apps, such as page-based apps, tab-based apps, games, spreadsheet apps, and more. These templates have a preset interface and source code files. .
For example, in the status bar on iOS, we have the most basic pattern of the app, which is “demo only”; We will use. To select this item, go to the iOS section on the left, select the application from the select section, and in the main part of the window that opens, select “single view application” and click on the next button, as shown below. .
After clicking Next, we will see a window like the one below, in this case we have to mention the project name and other details for our program.
Product name: “Status Bar in iOS” (Status bar in iOS)
The name we enter in the Product Name section is used for the project and application.
Organization name: “Tutlane”
You can enter the name of the organization or your name in this field; Of course you can leave that section blank.
Organization Identifier): “com.developersocociety)”
If you do not have an enterprise ID, enter com.example.
Bundle Identifier: This section is automatically generated based on the terms we entered in the product name and organization ID.
Language: “Swift”
Select the language type “Swift” because we want to develop applications using swift.
Universal (devices): “Universal”
Select the Devices option as Universal This means that this app is for all Apple devices; If you need to run the app for iPad only, you can select the iPad option to restrict your app to running only on iPad devices.
Use core Data: Not selected
This option is used for database operations. Select this option if you are doing any database-related operations in your application, otherwise do not select this option.
Include Unit Test: Not selected
If you need unit tests for your application, select this option otherwise leave it unselected.
Includes UI tests: not selected
Select this option if you need UI tests for your application, otherwise do not select it.
After completing the options, click the Next button as shown below.
When we click the Next button; A new window will open in which you must use the location where you want the new project to be saved; Let’s choose. Once you have selected the new project storage location; As shown below; Click the Create button.
After clicking the Create button, Xcode opens and creates a new project.
In our project, Main.storyboard and ViewController.swift are the main files used to design the user interface and maintain the source code.
Main.storyboard – which is the visual interface editor and this file is used to design the application interface.
ViewController.swift – which contains the source code of our application and we use this file to write any code related to our application.
Now select the Main.storyboard file in the project, until Xcode opens the visual interface editor as shown below.
Now open the ViewController.swift file in your project, which looks similar to the one below.
Then you need to open the ViewController.swift file and write the codes for hiding the status bar; As long as the program is running; Hide the status bar.
Import UIKit
Class ViewController: UIViewController {
Override func viewDidLoad () {
Super.viewDidLoad ()
// Do any additional setup after loading the view, typically from a nib.
}
override func didRecieveMemoryWarning () {
super.didRecieveMemoryWarning ()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear (animated: Bool) {
super.viewWillAppear (true);
navigationController? .navigationBar.hidden = true
UIApplication.sharedApplication (). StatusBarHidden = true;
}
}
Now run the program and check its output. To run the program; Select the required emulator (in this section we have selected iPhone Six S Plus) and click the Play button, which is similar to the one below in the upper left corner of the Xcode toolbar.
IOS status bar app output in Swift
You can see the iOS toolbar running below. If you pay attention to the following output; Status bar when the program is running; Is hidden.
This is how we can use the iOS app ui toolbar in our swift apps to hide or show the status bar; We can also change it according to our needs.