我想在屏幕中间显示我的反应本机模式,即使我已经完成了样式设置,但窗口出现在我的屏幕顶部但不在屏幕中心。这是我到目前为止所尝试的:
<Modal animationType = {"slide"} transparent = {true}
style={styles.modal}
visible = {this.state.modalVisible}
onRequestClose = {this.closeModal}>
<View style={{justifyContent: 'center', backgroundColor: '#ffff', margin: 0,
alignItems: 'center'}}>
<Text >Enter Email</Text>
<TextInput
underlineColorAndroid='transparent'
onChangeText={(email) => this.setState({email})}/>
<Text>Enter Password</Text>
<TextInput
secureTextEntry={true}
underlineColorAndroid='transparent'
onChangeText={(password) => this.setState({password})}/>
<TouchableHighlight onPress = {() => {
this.toggleModal(!this.state.modalVisible)}}>
<Text >Close</Text>
</TouchableHighlight>
</View>
</Modal>
这是模态样式:
const styles = StyleSheet.create({
modal:{
position:"relative",
width: 250,
height: 100,
backgroundColor: '#FFF',
justifyContent: 'center',
alignSelf: 'center',
}
});