4

I have one main view controller - > status bar style is light. In that i have one button to open user contacts. I am opening as present modal and i am changing the status bar style to dark. But on dismiss (by swipe down), in my main vc my status bar style is still in dark. It should automatically change to light. But this is not happening.

my code :

let navVC = UINavigationController(viewController: VC)
navVC.modalPresentationCapturesStatusBarAppearance = true
present(navVC, animated: true, completion: completion)

But from my open contact vc (present modal) , user can open two more vc as model.So my vc hierarchy will be -> Home --> opencontactvc (present). -> shownumbervc (present) -> seeuserphotoVC (present)

if i dimiss from seeuserphotoVC, i no need to change my status bar. I need to change my status bar only if i am in opencontactvc. So that it will land on home vc, that time i need to chnage my status bar.

my open contact vc :

override var preferredStatusBarStyle: UIStatusBarStyle {
    if #available(iOS 13.0, *) {
        if traitCollection.userInterfaceStyle == .light {
            return .darkContent
        } else {
            return .lightContent
        }
    } else {
        return .lightContent
    }
}

override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)
    setNeedsStatusBarAppearanceUpdate()
}

On dimiss (swipe to down), not sure why its not changing . Becasue when i swipe down to dismiss my viewwillAppear wont get call. So not sure how to handle that. Can we set it to automatically

britain chare
  • 89
  • 1
  • 6

1 Answers1

0

Check in your info.plist UIViewControllerBasedStatusBarAppearance and try switching it and see if it fix it. Also take a look to his answer

Regards!

juanjovn
  • 492
  • 4
  • 8