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

时间:2017-04-04 08:05:44

标签: ios xcode reactjs react-native react-native-ios

当React Native应用程序首先运行时,会出现如下截图的白色视图,如何更改该视图的背景颜色?我在Xcode中找不到该活动。

enter image description here

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

提前致谢。

2 个答案:

答案 0 :(得分:4)

我刚刚在AppDelegate.m

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

答案 1 :(得分:0)

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

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

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

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

相关问题