Big*_*n86 12 android ios react-native
我想知道如何解决一个启动画面,让我们说它出现了几秒钟,然后被其他视图取代?
我想在第一次启动应用程序时使用此功能并覆盖一些网络连接.
Big*_*n86 24
这就是我解决加载屏幕的方法.我使用Navigator Component.
在我的index.android.js
设置initialRoute
到我的SplashPage/SplashScreen类,然后在那里我设置一个超时链接到您想要在一定时间后跳转到的MainView.
我在index.android.js中的导航器:
<Navigator
initialRoute={{id: 'SplashPage'}}
renderScene={this.renderScene}
configureScene={(route) => {
if (route.sceneConfig) {
return route.sceneConfig;
}
return Navigator.SceneConfigs.HorizontalSwipeJump;
}}
/>
Run Code Online (Sandbox Code Playgroud)
我的initialRoute类:
class SplashPage extends Component {
componentWillMount () {
var navigator = this.props.navigator;
setTimeout (() => {
navigator.replace({
id: 'MainView', <-- This is the View you go to
});
}, 2000); <-- Time until it jumps to "MainView"
}
render () {
return (
<View style={{flex: 1, backgroundColor: 'red', alignItems: 'center', justifyContent: 'center'}}>
<Image style={{position: 'absolute', left: 0, top: 0, width: windowSize.width, height: windowSize.height}} source={require('image!splash_screen')}></Image>
</View>
);
}
}
module.exports = SplashPage;
Run Code Online (Sandbox Code Playgroud)
编辑
可能更有趣,因为它是"原生的";) https://github.com/crazycodeboy/react-native-splash-screen
归档时间: |
|
查看次数: |
19915 次 |
最近记录: |