反应 native:Unable 以将自定义高度设置为模态

react native:Unable to set custom height to modal

我是 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>

改为将您的高度设置为内容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>