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.
答
可能您可以使用 react-native-image-filter-kit 软件包.请注意,react-native-image-filter-kit的渐变最初被设计为与其他图像融合的基元,而您的情况并非一开始就被考虑在内.
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>
}
/>
)