ReactNative实现渐变色20-04-26

2020-04-26  本文已影响0人  你坤儿姐

使用react-native-linear-gradient插件
安装:
yarn add react-native-linear-gradient
react-native link react-native-linear-gradient
在ios端运行的别忘了
cd ios
pod install
导入:

import  LinearGradient from 'react-native-linear-gradient';
impor {
   BVLinearGradient
}from 'react-native';

使用:

<LinearGradient colors={['#9f678c', '#718697', '#2b4963']} style={styles.container}>
<View style={styles.header}>
<Text style={styles.header.text}>用户登录</Text>
</View>
</LinearGradient>

写完代码,记得重新运行项目,尤其是ios端,不然会爆找不到BVLinearGradient的错。
效果:

image
上一篇 下一篇

猜你喜欢

热点阅读