首页 > 解决方案 > 反应本机模式不向下滑动关闭

问题描述

我正在使用 react-native 的 modal 来显示更大的图像视图:

import {  Modal } from 'react-native'


<Modal
        animationType="slide"
        visible={this.state.modalOpen}
        presentationStyle="pageSheet"
        swipeDirection='down' 
        swipeThreshold={50} 
        onSwipeComplete={()=> this.closeImageModal()}
        onDismiss={() => this.closeImageModal()}>
            
        <View  style={{ flex: 1, backgroundColor: '#121212', justifyContent: 'center', alignItems: 'center'}}>
            <TouchableOpacity 
                style={{padding: 15}}
                onPress = { () => this.closeImageModal() }>
                <Ionicons name="ios-close-circle" size={30} color="red" />
            </TouchableOpacity>

            <Image
                source={{ uri: this.state.image }}
                style={styles.fullScreenImage}
            />
        </View>
    </Modal>

现在,我需要按下图像上方的可触摸不透明度来关闭模式。

我尝试过使用react-native-modal,它在我的应用程序中非常有问题并且难以使用,所以我决定坚持使用 react native 的模态。有什么方法可以实现向下滑动以关闭此模式,而无需使用react-native-modal

标签: react-nativeexpo

解决方案


推荐阅读