React Native:径向渐变背景 [英] React Native: Radial Gradient Background

查看:644
本文介绍了React Native:径向渐变背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于其中一个视图,是否有包装或以其他方式使用简单的蓝色(蓝色至蓝色)径向渐变背景?

Is there an package, or another way to have a simple, let's say blue to blueish, radial gradient background, for one of the views?

我已经尝试过 react-native-radial-gradient ,但是似乎已经过时了.

I've tried react-native-radial-gradient, but it seems like it's outdated.

推荐答案

可能您可以使用

Probably you can use RadialGradient from my react-native-image-filter-kit package. Note that gradients from react-native-image-filter-kit are initially designed as primitives for blending with other images and your case is not something that was taken into account in the first place.

import { Image } from 'react-native'
import {
  RadialGradient,
  ImageBackgroundPlaceholder
} from 'react-native-image-filter-kit'

const imageStyle = { width: 320, height: 320 }

const gradient = (
  <RadialGradient
    colors={['red', '#00ff00', 'blue']}
    stops={[0, 0.5, 1]}
    image={
      <ImageBackgroundPlaceholder style={imageStyle}>
        /* your content here */
      </ImageBackgroundPlaceholder>
    }
  />
)

这篇关于React Native:径向渐变背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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