iOS Development
Status Bar Style
View Controller
iOS 7
Mobile App Design

iOS 7 and later set status bar style per view controller

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

iOS 7 introduced a significant design overhaul and new features, one of them being the ability to set the status bar style per individual view controller. This functionality allows developers to customize the appearance of the status bar to match the unique design of each screen in their apps.

Status Bar Styles Overview

The status bar, visible at the top of the device screen, presents vital information such as the time, signal strength, and battery level. There are primarily three styles you can apply to the status bar:

Default: Black text with a light background (recommended for white backgrounds). • Light Content: White text with a dark background (ideal for dark backgrounds). • Dark Content: Black text with a light background (introduced in iOS 13, mainly for supporting dark mode).

Configuring Status Bar Style in iOS 7 and Later

Opting In with View Controller-Based Status Bar Appearance

Prior to iOS 7, setting the status bar style was a global setting, affecting every screen in the app. From iOS 7 onward, the `UIViewController` class provides flexibility through the `preferredStatusBarStyle` property. By default, iOS looks for this setting:

  1. Open your app's `Info.plist` file.
  2. Ensure the `UIViewControllerBasedStatusBarAppearance` key is set to `YES`. This enables the status bar's style to be determined on a per-view-controller basis.

Implementing the Status Bar Style

Below is a typical implementation example of changing the status bar style in a single view controller:

• (UIStatusBarStyle)preferredStatusBarStyle {

Home View Controller:

Detail View Controller:

Consistent Experience: Ensure a consistent visual experience by aligning the status bar style with your app’s design language across all view controllers. • Dynamic Changes: When dynamically changing the UI where the status bar style would need an update, ensure the screen layout is also adapted if required. • Testing: Thoroughly test in different environments, especially with devices running different iOS versions to confirm backward compatibility if you’re supporting older versions than iOS 13.


Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.