世博线性渐变透明显示为黑色 [英] Expo Linear Gradient transparent is showing up blackish

查看:22
本文介绍了世博线性渐变透明显示为黑色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Expo 线性渐变在我的 React Native 屏幕中实现从下到上的白色到透明白色的过渡:

实际上是透明的,所以这很好,但有没有办法给它一个白色的色调?

代码在这里:

 <LinearGradient颜色={['透明','rgba(255,255,255,0.8)']}风格={{位置:'绝对',左:0,对:0,底部:0,身高:200,}}/>

解决方案

因为transparent等于rgba(0,0,0,0)

尝试使用 rgba(255,255,255,0) 而不是透明来获得白色到白色的过渡

w3 规范将透明定义为 transparent black,可以阅读 这里

I'm trying to get a bottom to top white to transparent-white transition in my React Native screen using Expo Linear Gradients: https://docs.expo.io/versions/latest/sdk/linear-gradient.html

I copied the second example and flipped it around, and made it white instead of black. But now the "transparent" the white is supposed to fade in to is darker that the white is, see below:

The transparent actually is see through so that's good but is there a way to give it a white hue?

Code here:

     <LinearGradient
         colors={[ 'transparent', 'rgba(255,255,255,0.8)']}
         style={{
           position: 'absolute',
           left: 0,
           right: 0,
           bottom: 0,
           height: 200,
         }}
       />

解决方案

It's because transparent is equal to rgba(0,0,0,0)

Try using rgba(255,255,255,0) instead of transparent to get a white to white transition

The w3 spec defines transparent as transparent black as can be read here

这篇关于世博线性渐变透明显示为黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆