首页 > 其他分享 >RN 渐变组件

RN 渐变组件

时间:2022-08-29 14:23:09浏览次数:47  
标签:linear .. 渐变 react props 组件 import RN native

官网地址: https://github.com/react-native-linear-gradient
1.安装

yarn add react-native-linear-gradient

封装成简单的组件使用

import THButton from '../../component/THBUTTON/index'
<THButton style={{borderRadius: 20}}>获取验证码</THButton>
import React,{Component} from 'react';
import {StyleSheet, Text, TouchableOpacity} from 'react-native'
import LinearGradient from 'react-native-linear-gradient';

export default class THButton extends Component{
    constructor(props){
        super(props)
    }
    // 定义默认参数
    static defaultProps={
        style:{}
    }
    render(){
        return(
            <TouchableOpacity activeOpacity={.8} style={{width: "100%",overflow:'hidden', ...this.props.style}}>
                <LinearGradient start={{x: 0, y: 0}} end={{x:1,y:0}} colors={['#9b63cd', '#e0708c']} style={styles.linearGradient}>
                    <Text style={styles.buttonText}>
                        {this.props.children}
                    </Text>
                </LinearGradient>
            </TouchableOpacity>
        )
    }
}

// Later on in your styles..
var styles = StyleSheet.create({
  linearGradient: {
    flex: 1,
    paddingLeft: 15,
    paddingRight: 15,
    borderRadius: 5
  },
  buttonText: {
    fontSize: 18,
    fontFamily: 'Gill Sans',
    textAlign: 'center',
    margin: 10,
    color: '#ffffff',
    backgroundColor: 'transparent',
  },
});

 

标签:linear,..,渐变,react,props,组件,import,RN,native
From: https://www.cnblogs.com/tlfe/p/16635794.html

相关文章

  • RN关闭黄色警告
    放在index.js下AppRegistry.registerComponent(appName,()=>App);之前//关闭黄色警告console.ignoredYellowBox=['Warning:BackAndroidisdeprecated.Pleaseu......
  • 报错:ReferenceError: __dirname is not defined in ES module scope
    报错:__dirnameisnotdefinedinESmodulescope前言新版NodeJS支持通过ESM方式导入模块,代码如://CommonJS规范(旧)const{readFileSync,writeFileSync}=r......
  • tiangolo/uvicorn-gunicorn:python3.8 fastapi docker部署
    经验教训:1、gunicornlog文件固定放置在容器中目录:/code/logs,所以这个目录必需映射出来;2、按照fastapi官方建议,uvicorn运行目录:/app,所以这个目录要映射到代码目录;3、......
  • 057_末晨曦Vue技术_处理边界情况之强制更新和创建低开销的静态组件
    强制更新和创建低开销的静态组件点击打开视频讲解更加详细强制更新如果你发现你自己需要在Vue中做一次强制更新,99.9%的情况,是你在某个地方做错了事。你可能还没有留......
  • git时:OpenSSL SSL_read: Connection was reset, errno 10054
    OpenSSLSSL_read:Connectionwasreset,errno10054...处理方法Solution1:(原因)更新DNS缓存。在cmd中输入以下命令:ipconfig/flushdnsSolution2:(原因)文件太大了......
  • Linux Kernel in a Nutshell - 7
    CustomizingaKernel原文链接我的博客以·问题·做关键字搜索,还有问题构建你自己的Linux内核版本最困难的部分,应该就是确定哪一个驱动以及配置选项是你的设备需要的......
  • Linux Kernel in a Nutshell - 8
    KernelConfigurationRecipes原文链接我的博客前面介绍了重新配置内核的机制,本章介绍制作自己的内核通常会遇到的那些问题,并给出对应指令来处理它。DisksLinux内核......
  • 内容区滚动组件封装
    iScroll5API中文版观察器温馨提示:让iscroll内容滚动,首先iscroll容器的高度,必须小于内容区的高度没设置内容区的高度就滚动不了了容器的高等于可视区的高度,可视区......
  • k8s(kubernetes)基于(NFS+PV+PVC)部署jenkins
    #部署流程:(系统:centos7.9)一、设置存储目录1、安装NFS服务端2、挂载NFS并设置存储文件夹二、创建PV&PVC1、准备PV&PVC部署文件2、创建PV&PVC......
  • 在 React 中释放 Web 组件的力量
    在React中释放Web组件的力量Photoby法提赫on不飞溅假设您有一个项目,要求您在React应用程序中使用Web组件。你如何使用该组件的状态?如何访问它的方法和属......