![](/img/trans.png)
[英]How can I display a launch/splash screen in a react-native app without using a package? (iOS specifcally)
[英]react-native or iOS iphone App Webview Splash image
我的目標是顯示啟動畫面,直到我的Webview網址完全加載。 它是本機應用程序的反應,但我想任何iOS建議都可以。 那可能嗎?
要在加載應用程序時顯示啟動畫面,您可以在Github上簽出該項目: react-native-splashscreen 。
可以使用npm安裝:
npm install react-native-splashscreen --save
用法:
'use strict';
var React = require('react-native');
var {
AppRegistry,
View,
Text,
} = React;
var SplashScreen = require('@remobile/react-native-splashscreen');
var SplashViewApp = React.createClass({
componentDidMount: function() {
SplashScreen.hide();
},
render() {
return(
<View>
<Text>
Lorem Ipsum..
</Text>
</View>
);
}
});
AppRegistry.registerComponent('SplashViewApp', () => SplashViewApp);
否則請使用諸如react-native-loading-spinner-overlay之類的東西 。 通過以下方式安裝:
npm install --save react-native-loading-spinner-overlay
使用方法如下:
import React, { View } from 'react-native';
import Spinner from 'react-native-loading-spinner-overlay';
class MyComponent extends React.Component {
constructor(props) {
super();
this.state = {
visible: false
};
}
/* eslint react/no-did-mount-set-state: 0 */
componentDidMount() {
setInterval(() => {
this.setState({
visible: !this.state.visible
});
}, 3000);
}
render() {
return (
<View style={{ flex: 1 }}>
<Spinner visible={this.state.visible} />
</View>
);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.