Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working when start app on landscape mode #2

Open
mohsinbmwm3 opened this issue Nov 28, 2019 · 2 comments
Open

Not working when start app on landscape mode #2

mohsinbmwm3 opened this issue Nov 28, 2019 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@mohsinbmwm3
Copy link

Not working when start app on landscape mode.
iOS 13.2.2, iPhone 11
Start app on landscape mode and rotate to portrait. Status bar not showing up.
It works only when we start app on portrait mode

@WrathChaos WrathChaos self-assigned this Nov 28, 2019
@WrathChaos WrathChaos added the bug Something isn't working label Nov 28, 2019
@WrathChaos
Copy link
Owner

I'm gonna find a solution for this one, thank you for the reporting

@nthtrung09it
Copy link

Hello, here is my solution:

   fileprivate var customStatusBarHeightConstraint: NSLayoutConstraint?
if #available(iOS 13.0, *) {
            let app = UIApplication.shared
            let statusBarHeight: CGFloat = app.statusBarFrame.size.height

            let statusbarView = UIView()
            statusbarView.backgroundColor = UIColor.white
            view.addSubview(statusbarView)

            statusbarView.translatesAutoresizingMaskIntoConstraints = false
            customStatusBarHeightConstraint = statusbarView.heightAnchor
                .constraint(equalToConstant: statusBarHeight)
            customStatusBarHeightConstraint?.isActive = true
            statusbarView.widthAnchor
                .constraint(equalTo: view.widthAnchor, multiplier: 1.0).isActive = true
            statusbarView.topAnchor
                .constraint(equalTo: view.topAnchor).isActive = true
            statusbarView.centerXAnchor
                .constraint(equalTo: view.centerXAnchor).isActive = true
        } else {
            let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView
            statusBar?.backgroundColor = UIColor.white
        }
override func viewWillLayoutSubviews() {
       super.viewWillLayoutSubviews()

       if let customStatusBarHeightConstraint = customStatusBarHeightConstraint {
           let statusBarHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height
           if customStatusBarHeightConstraint.constant != statusBarHeight {
               customStatusBarHeightConstraint.constant = statusBarHeight
           }
       }
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants