React Native:更改初始加载视图的背景颜色

React Native: change background color of initial loading view

当 React Native 应用程序最初是 运行 时,有一个白色的视图,如下图所示,我该如何更改该视图的背景颜色?我在 Xcode 中找不到 activity。

因为在某些情况下,我重新启动应用程序,并且用户看到一个闪光灯(上面的白色屏幕),所以我需要更改背景颜色。

提前致谢。

我刚刚在 AppDelegate.m

中找到它
rootView.backgroundColor = [[UIColor alloc] initWithRed:0.0f green:0.64f blue:0.87f alpha:1];

尝试更改 LaunchScreen 文件。这是您的应用程序打开时显示的第一件事(如果您的捆绑时间太长,您将再次看到白屏。IMO 最佳做法是使用 splash screen

使用启动画面,您可以在 componentDidMount() 函数中关闭启动视图(可能是图像),如下所示。

componentDidMount() {
   // do anything while splash screen keeps, use await to wait for an async task.
   SplashScreen.hide();
}

另请注意,在生产版本中,不会从本地服务器进行捆绑,因此暂时无需担心。