2

I am attempting to change the text color of the status bar from black to white on a Modally Presented View Controller embedded in a Navigation Controller called ChildViewController

I am using the Chameleon framework for colors.

I can change the background color with no issues using:

guard let navBar = navigationController?.navigationBar else {fatalError("Navigation controller does not exist.")}
guard let navBarColour = UIColor(hexString: colourHexCode) else { fatalError()}

navBar.barTintColor = navBarColour
navBar.tintColor = ContrastColorOf(navBarColour, returnFlat: true)
navBar.largeTitleTextAttributes = [.foregroundColor : ContrastColorOf(navBarColour, returnFlat: true)]

I have tried multiple combination of the below in viewWillAppear & viewDidLoad in ChildViewController

self.modalPresentationCapturesStatusBarAppearance = true

UIApplication.shared.statusBarStyle = .lightContent

setNeedsStatusBarAppearanceUpdate()

setStatusBarStyle(.lightContent)


override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

I have even tried Chameleons own self.setStatusBarStyle(UIStatusBarStyleContrast) but again nothing is working.

In my Info.plist I have:

View controller-based status bar appearance = YES

And in the General Project settings under Deployment Info the Status Bar Style is set to Default

Targeting iOS 11.4 with Swift 4.1

What am I doing wrong?

user-44651
  • 3,924
  • 6
  • 41
  • 87

0 Answers0