Marc t
Marc t

Reputation: 129

Prevent changing status bar when opening page with popover

I open a page programmatically with popover, the theme of the app is light so the status bar labels are black. But when the popover gets open, the the labels are status bar also gets white and nothing can be seen in the status bar.

here is the screenshot link

here is the code to open popover

 func showlistCard() {
     let vc = ContainerlistCard()
     vc.modalPresentationStyle = .popover
     present(vc, animated: true, completion: nil)
 }

Then I searched, and I found out that I can change the style of status bar with these code

 public override var preferredStatusBarStyle: UIStatusBarStyle {
       return .default
  }

and in the viewWillAppear

 if #available(iOS 13.0, *) {
      overrideUserInterfaceStyle = .light
 }

I added it in both page, the page that open the popover and the page that gets opened, both of them are not working for me. Any suggestion? many thanks

Upvotes: 1

Views: 105

Answers (1)

Frankenstein
Frankenstein

Reputation: 16341

If you are trying to set the status bar for the entire app all you need to do is:

  1. In Info.plist set the View controller-based status bar appearance to NO
  2. Left side of XCode slect project > Targets > Select your project > Under General > Deployment Info > Select Status Bar Style: Light

Upvotes: 0

Related Questions