美文网首页
Modal频繁显示隐藏

Modal频繁显示隐藏

作者: 阿泽Leo | 来源:发表于2019-06-27 11:12 被阅读0次

在IOS下,使用RN原生的Modal,频繁的显示和隐藏会出现一直不消失的bug。

  • 解决方法:使用第三方库react-native-root-modal,安装方法看里面的文档。

  • 使用方法:使用原生的写好后,替换Modal的导入

import Modal from 'react-native-root-modal';

然后在Modal上添加相应的style:

....other elements before
<Modal
    style={{
        top: 0,
        right: 0,
        bottom: 0,
        left: 0,
        backgroundColor: 'rgba(0, 0, 0, 0.2)',
        transform: [{scale: this.state.scaleAnimation}]
    }}

    visible={this.state.modalVisible}
>
    ... You can add anything inside
</Modal>
....other elements after

重新启动应用,完成。

相关文章

网友评论

      本文标题:Modal频繁显示隐藏

      本文链接:https://www.haomeiwen.com/subject/tzulcctx.html