react-native - 如何在 react-native 中围绕圆圈制作渐变边框?我正在使用 LinearGradient 但它填充了圆圈
问题描述
我希望黑色边框是渐变的,我希望圆圈是透明的。我可以使用一个单独的库还是有办法解决这个问题?
<LinearGradient
colors={['#00FFFF', '#17C8FF', '#329BFF', '#4C64FF', '#6536FF', '#8000FF']}
start={{x: 0.0, y: 1.0}} end={{x: 1.0, y: 1.0}}
style={styles.CircleShapeView}
>
</LinearGradient>
CircleShapeView: {
position: 'absolute',
top: 1,
left:50,
right: 0,
bottom: 0,
width: Dimensions.get('window').height /3,
height: Dimensions.get('window').height /3,
borderRadius: Dimensions.get('window').height / 2,
backgroundColor: 'transparent',
borderStyle: 'solid',
borderWidth: 5,
borderColor: 'black',
},
解决方案
您不能将其作为边框,但您可以在线性渐变内创建一个视图以获得相同的效果。
这是一个可以测试的小吃:https ://snack.expo.dev/@truetiem/border-gradient
<LinearGradient
colors={['#00FFFF', '#17C8FF', '#329BFF', '#4C64FF', '#6536FF', '#8000FF']}
start={{ x: 0.0, y: 1.0 }}
end={{ x: 1.0, y: 1.0 }}
style={{
width: 200,
height: 200,
borderRadius: 100,
padding: 5, // This should be the border width you want to have
overflow: 'hidden',
}}>
<View
style={{
flex: 1,
borderRadius: 100,
backgroundColor: '#ecf0f1',
alignItems: 'center',
justifyContent: 'center',
}}>
<Text>Your content goes here</Text>
</View>
</LinearGradient>
推荐阅读
- python-3.x - 求素数的函数
- netsuite - SDF 部署错误:部分内容
- flutter - Dart 动画 MaterialApp 主屏幕
- ios - AutoLayout:需要 Y 位置或高度的约束(尝试使用具有动态高度内容的视图)
- angular - 如何在 angularListObservable 上使用异步
- java - 将 JSON 字符串从片段传递到适配器的问题
- javascript - ES6 groupBy、分区、排序对象列表
- numpy - 区间端点附近的四阶数值导数误差
- mysql - 不幸的是删除了 mysql.user 表中的所有用户。我如何创建新用户
- bash - Bash:如何在 Top 命令中显示特定 java -jar 的名称?