Expo:如何以编程方式更改飞溅图像?
我有一个React Native Expo app.json,如下所示:Expo:如何以编程方式更改飞溅图像?,expo,splash-screen,Expo,Splash Screen,我有一个React Native Expo app.json,如下所示: { "expo": { "name": "Awesome App", "splash": { "image": "./assets/images/splash.jpg", }, ... } 在我的应用程序中,我希望允许用户从图像列表(从服务器加载)中选择一个图像,并且该图像将在用户下次启动应用程序时显示在启动屏幕中 如何使用Expo实现这一点?您将使用react导航。只需在st
{
"expo": {
"name": "Awesome App",
"splash": {
"image": "./assets/images/splash.jpg",
},
...
}
在我的应用程序中,我希望允许用户从图像列表(从服务器加载)中选择一个图像,并且该图像将在用户下次启动应用程序时显示在启动屏幕中
如何使用Expo实现这一点?您将使用react导航。只需在stackNavigator中添加splashScreen
export default StackNavigator({
SplashScreen: { screen: SplashScreen },
AuthScreen: { screen: AuthScreen },
MainNavigator: { screen: MainNavigator }
}, {
headerMode: 'screen',
navigationOptions: {
header: { visible: false }
}
})
加上超时。在我的例子中
componentDidUpdate () {
if (this.state.isAppReady) {
if (this.state.isLoggedIn) {
this.props.navigation.navigate('MainNavigator');
} else {
this.props.navigation.navigate('AuthScreen');
}
}
}
您可以在渲染中更改图像。此方法适用于Expo加载我们的应用程序后。