Change Status Bar text color in iOS

When you need to change the text color of status bar to white in order to enhance visibility you can proceed as shown below

  1. Set the UIViewControllerBasedStatusBarAppearance to YES in the .plist file.
  2. In the viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];
  3. Add the following method:
- (UIStatusBarStyle)preferredStatusBarStyle
    return UIStatusBarStyleLightContent; 

In order to cater for ViewControllers embedded in a NavigationController use this insted

// Preferred status bar style lightContent for dark background.
override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent


For swift UI add a custom hosting file

//Created by Amarendra

import Foundation
import UIKit
import SwiftUI

class HostingController: UIHostingController<ContentView> {
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent

Now you need to update the Scenedelegate.swift to use your own HostingController.swift

// replace this line window.rootViewController = UIHostingController(rootView: ContentView())
window.rootViewController = HostingController(rootView: ContentView())

Hope this helps !!!

A pat on the back !!