【问题标题】:Changing status bar colour in React Native在 React Native 中更改状态栏颜色
【发布时间】:2021-04-27 01:25:58
【问题描述】:

在 React Native 中,我尝试将状态栏设置为“浅色内容”,以便在较暗的背景下更明显。为此,我使用了 ,但是当我运行代码时出现以下错误:


RCTStatusBarManager module requires that the                 UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO
-[RCTStatusBarManager setStyle:animated:]
    RCTStatusBarManager.mm:157
__invoking___
-[NSInvocation invoke]
-[NSInvocation invokeWithTarget:]
-[RCTModuleMethod invokeWithBridge:module:arguments:]
facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&)
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start
0x0

我进入 info.plist 页面并根据错误消息将 UIViewControllerBasedStatusBarAppearance 设置为 false,但仍然没有做任何事情。

【问题讨论】:

    标签: android ios react-native uistatusbar react-typescript


    【解决方案1】:

    在iOS上,你只能通过https://reactnative.dev/docs/statusbar#barstyle改变StatusBar的theme

    在Android上,你可以使用backgroundColor props https://reactnative.dev/docs/statusbar#backgroundcolor-android

    【讨论】:

      猜你喜欢
      • 2019-03-10
      • 1970-01-01
      • 2016-03-08
      • 1970-01-01
      • 2017-10-10
      • 1970-01-01
      • 2018-07-05
      • 1970-01-01
      • 2023-03-31
      相关资源
      最近更新 更多