Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
react-native中的Css线性梯度_Css_React Native - Fatal编程技术网

react-native中的Css线性梯度

react-native中的Css线性梯度,css,react-native,Css,React Native,我试图使用react native linear gradient为视图实现类似css的线性渐变,但插件只允许2种颜色,不允许我将渐变设置为径向,这是线性渐变linear gradient的css格式(151.76度,#EE8F62-43.83%,rgba(239、203、113、0.96)97.18%,rgba)(242、172、136、0.15)120.83%);,请问如何使用插件实现上述功能,我已经尝试过了 <LinearGradient colors={[rgba(239, 203

我试图使用
react native linear gradient
为视图实现类似css的线性渐变,但插件只允许2种颜色,不允许我将渐变设置为径向,这是线性渐变
linear gradient的css格式(151.76度,#EE8F62-43.83%,rgba(239、203、113、0.96)97.18%,rgba)(242、172、136、0.15)120.83%);
,请问如何使用插件实现上述功能,我已经尝试过了

<LinearGradient colors={[rgba(239, 203, 113, 0.96), rgba(242, 172, 136, 0.15)]} >

您不能像在CSS中那样使用React Native中的百分比值。但是,您可以使用以下值为渐变提供角度:

start={{x: 0, y: 1}} 
end={{x: 1, y: 0}}
例如:

<LinearGradient
     start={{x: 0, y: 1}} end={{x: 1, y: 0}}
     colors={['rgba(204,49,125,0.95)', 'rgba(255,117,84,0.95)', 'rgba(204,49,125,0.95)']}
     style = { styles.container }>

         {Your code here}

</LinearGradient>

{您的代码在这里}

上面的代码生成一个从左下角开始到右上角结束的线性渐变。渐变的不透明度为0.95。

看起来库还不支持径向渐变。。