简体   繁体   English

如何在本机反应中逐渐模糊?

[英]How to make gradual blur in react native?

Should get a gradient bluer like the design, but I can't do it, any ideas?应该得到一个像设计一样的渐变蓝色,但我做不到,有什么想法吗?

what it should look like它应该是什么样子

This is how my code look这就是我的代码的样子

<ImageBackground 
    source={{uri: uri}} 
    style={styles.imageBackground} 
    imageStyle={styles.imageStyleBackground}
  >
      <BlurView
        style={{width: width * 0.78}}
        >
        <Text style={styles.date}>{date}</Text>
        <Text style={styles.title}>{title}</Text>
      </BlurView>
  </ImageBackground>

I try to use BlurView component, but it doesn't work the way it's supposed to.我尝试使用 BlurView 组件,但它没有按预期的方式工作。

Try with position: 'absolute'尝试使用 position: 'absolute'

 <> <Image source={{uri: uri}} style={styles.imageStyleBackground} /> <BlurView style={{width: width * 0.78, position: 'absolute'}}> <Text style={styles.date}>{date}</Text> <Text style={styles.title}>{title}</Text> </BlurView> </>

You could add an element on top of the image with backdrop-filter:blur(5px) that is masked with a gradient (eg. mask linear-gradient(black, black, transparent) )您可以使用backdrop-filter:blur(5px)使用渐变遮罩(例如 mask linear-gradient(black, black, transparent)

在此处输入图像描述

See https://codepen.io/QuiteQuinn/pen/jOBxGjr .请参阅https://codepen.io/QuiteQuinn/pen/jOBxGjr

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM