在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
重新启动应用,完成。
网友评论