朋友,使用React Native中的動畫隱藏和顯示視圖v0.46。
我有問題隱藏和顯示反應原生視圖。我已經做了下面的代碼。想用動畫隱藏和顯示視圖。請幫幫我。
代碼:
import React, { Component } from "react";
import {
AppRegistry,
Image,
View,
Text,
Button,
StyleSheet,
TouchableHighlight,
} from "react-native";
import { StackNavigator } from "react-navigation";
import SignUpScreen from "./SignUp";
import AddManagerScreen from "./AddManager";
class SplashScreen extends Component {
constructor(props) {
super(props);
this.state = {
isModalVisible : true,
}
}
static navigationOptions = {
title: 'DashBoard',
};
ShowView(){
this.state.isModalVisible = true;
console.log(this.state.isModalVisible);
if (this.state.isModalVisible) {
return(
<View style={styles.container}>
<View style = {[styles.overlayView , {display : 'flex'}]}>
</View>
</View>
);
}else{
return null;
}
//this.refs.secondView.getDOMNode().style.display="none";
}
render() {
console.log(this.state.isModalVisible);
console.disableYellowBox = true;
const { navigate } = this.props.navigation;
if (this.state.isModalVisible) {
return (
<View style={styles.container}>
<Image style={{width: '100%', height: '100%'}}
source={require("./Images/background.png")} />
<View style={styles.viewStyle}>
<TouchableHighlight style = {styles.buttonStart}
onPress={() => navigate("SignUp")}>
<Image
source={require('./Images/hire.png')}
/>
</TouchableHighlight>
<TouchableHighlight style = {styles.buttonEnd}
onPress={() => this.ShowView()}>
<Image style = {{marginBottom : 0}}
source={require('./Images/call.png')}
/>
</TouchableHighlight>
</View>
</View>
);
}else{
return(
<View style={styles.container}>
<View style = {[styles.overlayView , {display : 'flex'}]}>
</View>
</View>
);
}
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: "#FFFFFF",
flex: 1,
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
} ,
viewStyle :{
width: '100%',
height : '46%',
position : 'absolute',
backgroundColor : 'red',
alignItems: "flex-start",
justifyContent: "flex-start",
},
buttonStart :{
width: '100%',
height : '60%',
alignItems: "flex-start",
justifyContent: "flex-start",
},
buttonEnd :{
width: '100%',
height : '40%',
alignItems: "flex-end",
justifyContent: "flex-end",
},
overlayView :{
width: '100%',
height : '100%',
position : 'absolute',
backgroundColor : 'red',
}
});
const Apple = StackNavigator(
{
Splash: { screen: SplashScreen },
SignUp: { screen: SignUpScreen },
AddManager : { screen : AddManagerScreen},
},
{
headerMode: 'Splash' ,
// initialRouteName: "Splash" ,
}
);
AppRegistry.registerComponent("Apple",() => Apple);
欲解決方案V 0.46在反應機。
謝謝。
錯誤是什麼? –
@ShubhamSingla沒有錯誤,但隱藏視圖不顯示。 –