我有一个圆形视图,我想使用在 0 和 1 之间变化的 Animated.Value 为边框的颜色设置动画。按照https://facebook.github.io/react-native/docs/animated的指南进行操作
borderColor: this.state.active.interpolate({
inputRange: [0, 1],
outputRange: ['rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 1)']
})
这会在应用程序 (Android) 中创建警告:
index.android.bundle:29278Warning: Failed propType: Invalid prop `borderColor` supplied to `View`: [object Object]
Valid color formats are
- '#f0f' (#rgb)
- '#f0fc' (#rgba)
- '#ff00ff' (#rrggbb)
- '#ff00ff00' (#rrggbbaa)
- 'rgb(255, 255, 255)'
- 'rgba(255, 255, 255, 1.0)'
- 'hsl(360, 100%, 100%)'
- 'hsla(360, 100%, 100%, 1.0)'
- 'transparent'
- 'red'
- 0xff00ff00 (0xrrggbbaa)
Bad object: {
"borderWidth": 2,
"justifyContent": "center",
"alignItems": "center",
"width": 200,
"height": 200,
"borderRadius": 100,
"borderColor": "rgba(0, 0, 0, 0)"
} Check the render method of `Circle`.
从上面的警告来看,borderColor 似乎是正确的。 但是,它仍然发出警告。
通过使用<Animated.View>
而不是<View>
修复它
最有用的评论
通过使用
<Animated.View>
而不是<View>
修复它