0

我是 react-native 的新手,我正在尝试使用以下代码为模态提供自定义高度并在屏幕中居中。

  <Modal visible={this.state.isModalVisible} animationType = "slide" transparent = {false} 
     onRequestClose={this.closeModal} style={{ height:300 }}>
            <View style={{
               flex: 1,
               flexDirection: 'column',
               justifyContent: 'center',
               alignItems: 'center',
               backgroundColor:'blue'
              }}>
            <View>
             <Text style={{ fontWeight:'bold', fontSize: 20, color: '#f79334', marginTop: 15 
        }} > Services </Text>
            </View>
            </View>
  </Modal>
4

1 回答 1

2

将您的高度设置为View内容

   <Modal style={{  margin: 0, alignItems: 'center', justifyContent: 'center' }}>
      <View
        style={{
          height: 400,
          width: '100%',
          justifyContent: 'center',
          alignItems: 'center',
          backgroundColor: 'blue',
        }}
      >
        <View>
          <Text
            style={{
              fontWeight: 'bold',
              fontSize: 20,
              color: '#f79334',
              marginTop: 15,
            }}
          >
            Services
          </Text>
        </View>
      </View>
</Modal>
于 2020-03-07T09:22:09.660 回答