question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support the default value of UIViewControllerBasedStatusBarAppearance (true)

See original GitHub issue

Description

React Native currently requires that UIViewControllerBasedStatusBarAppearance is set to NO. This is an app-global setting and Apple offers this to help bringing old (pre-iOS 7) apps over to newer OS versions. It’s not recommended that this is set for new apps. The methods for manual status bar control are already deprecated and Apple explicitly discourages using them:

To opt out of the view controller-based status bar appearance behavior, you must add the UIViewControllerBasedStatusBarAppearance key with a value of false to your app’s Info.plist file, but doing so is not recommended. https://developer.apple.com/reference/uikit/uiapplication/1622923-setstatusbarstyle#discussion

The check was added in 2015: https://github.com/facebook/react-native/blame/64a4c6070df7e711e7fd01c490f369bbd0d0fb28/React/Modules/RCTStatusBarManager.m#L109-L111

At PSPDFKit we offer a React Native module. We also have a very similar check that warns if the value of UIViewControllerBasedStatusBarAppearance is still set to the old behavior. https://pspdfkit.com/blog/2016/react-native-module/

Here’s our FAQ article about it: https://pspdfkit.com/guides/ios/current/faq/uiviewcontrollerbasedstatusbarappearance/

Other platforms (Xamarin) are switching to the new style as well: https://github.com/xamarin/Xamarin.Forms/pull/463

Reproduction

See the code check for UIViewControllerBasedStatusBarAppearance. React should either support both or just default to the non-deprecated style. Currently any modification of the status bar requires this key to be set to false (true is the default)

Solution

This is tricky. See the related discussion on Twitter with Nick who wrote the original check: https://twitter.com/nicklockwood/status/816334935422337025

I realize that React doesn’t own the parent View Controller. There are still quite a few ways how the parent VC can be accessed and how hooks could be installed to both have the current flexibility (so we do not break any API) and offer compatibility with the new way of controlling the status bar.

I am willing to help and work on this but I’d first love to hear if there are any discussions around this that I missed while searching for it and what the mid- to long-term plans here are. I know that everything related to the status bar on iOS is painful, so I’m apologizing in advance for bringing up this issue.

Additional Information

  • React Native version: 0.39
  • Platform: iOS
  • Operating System: MacOS

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:34
  • Comments:32 (15 by maintainers)

github_iconTop GitHub Comments

14reactions
steipetecommented, Nov 3, 2017

Is nobody else running into this issue?

7reactions
steipetecommented, Aug 24, 2017

@hramos This is a conceptual issue and I have not seen a fix for it yet - please re-open this ticket.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TN3105: Customizing the UIKit status bar style
To allow individual view controllers to determine their status bar style, set UIViewControllerBasedStatusBarAppearance to true . First, add the ...
Read more >
Peter Steinberger on Twitter: "“RCTStatusBarManager ...
Supporting both variants in a large product is borderline ... Support the default value of UIViewControllerBasedStatusBarAppearance (true) ...
Read more >
iOS 13 status bar style - Stack Overflow
I define UIUserInterfaceStyle as Light in info.plist (as I do not want to support dark mode) and set UIViewControllerBasedStatusBarAppearance to ...
Read more >
How to fix wrong status bar orientation in iOS - onmyway133
Most apps only support portrait mode, with 1 or 2 screens being in ... Setting UIViewControllerBasedStatusBarAppearance to true means we ...
Read more >
How to set status bar style - Sarunw
The default color of the status bar is black text. ... key ( UIViewControllerBasedStatusBarAppearance ) and set value to No ( false )....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found