return (
<View style={styles.mainWrap}>
<StatusBar barStyle="default" />
<View style={styles.contentWrap}>
<Image
style={{ width: 50, height: 50 }}
source={{ uri: "https://facebook.github.io/react/img/logo_og.png" }}
/>
<Text>{`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum facilisis arcu vitae odio volutpat, non efficitur metus congue. Donec porttitor eu nibh a viverra. Vestibulum efficitur ex eu enim elementum, feugiat vulputate turpis efficitur. Suspendisse id enim tempor, malesuada velit eget, ultrices nunc. Suspendisse lorem velit, maximus a sem et, consectetur aliquam ligula. Morbi mauris justo, faucibus sit amet iaculis at, finibus non erat. Suspendisse aliquet augue ex, at efficitur purus tincidunt sit amet. Vestibulum faucibus leo eget odio eleifend, ut facilisis eros euismod. Duis sit amet est felis. Fusce ullamcorper diam et urna facilisis, imperdiet dignissim arcu sagittis. Integer sed lacus tortor. Ut vel mauris vitae magna consectetur suscipit sit amet at nisi.`}</Text>
<TouchableOpacity
onPress={() => {
this.launchModal(true);
}}
>
<Text>{`Launch modal`}</Text>
</TouchableOpacity>
</View>
<Modal
visible={this.state.modalVisible}
transparent={true}
animationType="fade"
>
<BlurView blurType="light" style={styles.contentWrap}>
<Image
style={{ width: 300, height: 150 }}
source={{
uri: "http://facebook.github.io/origami/public/images/blog-hero.jpg",
}}
/>
<Text>{`This is the modal!`}</Text>
<TouchableOpacity
onPress={() => {
this.launchModal(false);
}}
>
<Text>{`Close modal`}</Text>
</TouchableOpacity>
</BlurView>
</Modal>
</View>
);
5条答案
按热度按时间kyks70gy1#
你不需要使用任何库来实现这个模糊效果。下面是当模态打开时模糊背景图像的代码。
qxsslcnc2#
我找到了解决办法。这是“React原生”:“0.57.8”,“React-自然-模糊”:“^3.2.2”
nnt7mjpx3#
你应该试试这个
zvms9eto4#
把
BlurView
组件直接放进Modal
中,并赋予它下面的样式,我已经修复了它。不过,你应该注意,模糊的强度只影响iOS,Android有一个固定的模糊效果,无论intensity
属性如何。laik7k3q5#
只是添加
backgroundColor: 'rgba(0,0,0,0.5)'
到(style.modal)容器视图的样式