【发布时间】:2019-03-30 02:19:35
【问题描述】:
我正在尝试将自定义图像源添加到名为 react-native-circle-button 的 React Native 库中的属性 iconButtonCenter。 https://github.com/dwicao/react-native-circle-button
根据文档,iconButtonCenter 是枚举类型,因此我导入了图标,然后将其直接传递到我创建 CircleButton 对象的位置。它不会像数字或字符串那样大喊大叫,但我仍然不能 100% 确定它在技术上是枚举类型。我知道事实上它是在正确的路径中找到图像。我也知道它正在做某事,因为默认图像在应用程序上不再可见,它不再有图标。我没有收到任何编译错误或警告,但我仍然没有看到按钮上出现应有的图标。我该如何解决这个问题?
这是我的组件中允许拖动圆形按钮的渲染。我还继续将我的导入放在顶部,这样你就可以看到它是如何存储的。
import letterA from '../assets/letters/alpha-a.svg';
render() {
let { pan } = this.state;
let [translateX, translateY] = [pan.x, pan.y];
let moveableStyle = {transform: [{translateX}, {translateY}]};
const panStyle = {
transform: this.state.pan.getTranslateTransform()
}
return (
<Animated.View
{...this._panResponder.panHandlers}
style={[moveableStyle, panStyle]}>
<CircleButton iconButtonCenter={letterA} /> <--- Here is the image source reference.
</Animated.View>
);
}
CircleButton 组件应该成功地将图像提供给它,并且即使沿字符串拖动也能保持在按钮的中心。
【问题讨论】:
标签: react-native