将状态栏的样式从现在的模式重新恢复到驳回状态栏的样式。

问题描述 投票:0回答:1

我有一个主视图控制器-->状态栏样式是轻的。我有一个按钮来打开用户联系人。我以当前模式打开,并将状态栏样式改为深色。但是当删除时(向下滑动),在我的主视图中,我的状态栏样式仍然是深色的。它应该自动变为亮色。但这并没有发生。

我的代码:

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

但是从我的open contact vc(当前模式)中,用户可以打开另外两个vc作为模型,所以我的vc层次结构将是-> Home --> opencontactvc (present). -> shownumbervc (present) -> seeuserphotoVC (present)

如果我从 seeuserphotoVC 中消失,我不需要改变我的状态栏。只有当我在opencontactvc中时,我才需要改变我的状态栏。为了使它能登陆到主页vc,那个时候我需要改变我的状态栏。

我的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()
}

我的open contact vc:在dimiss(向下滑动),不知道为什么它没有改变。因为当我向下滑动解散时,我的viewwillAppear不会接到电话。所以不知道该如何处理。我们可以设置为自动

ios swift iphone xcode ios13
1个回答
0
投票

检查你的info.plist UIViewControllerBasedStatusBarAppearance 并尝试切换它,看看它是否修复它。也可以看看他的 回答

谢谢

© www.soinside.com 2019 - 2024. All rights reserved.