我正在尝试将一个自定义图像源添加到React Native库的iconButtonCenter属性中,名为react-native-circle-button。https://github.com/dwicao/react-native-circle-button
根据文档,iconButtonCenter是枚举类型,所以我导入了图标,然后直接在创建CircleButton对象的位置传递它。它不会像数字或字符串那样叫喊,但从技术上讲,我仍然不能百分之百确定它是枚举类型。我知道,事实上,它是在正确的道路上找到图像。我也知道它在做一些事情,因为默认图像在应用程序上不再可见,它只是不再有图标。我没有收到任何编译错误或警告,但我仍然没有看到图标出现在按钮上。我该如何解决这个问题?
这是我的组件中的渲染,它允许圆形按钮是可拖动的。我还将我的导入放在顶部,这样您就可以看到它是如何存储的。
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组件应该成功地将图像馈送到它,并且即使在沿字符串拖动时也保持在按钮上方的中心位置。
发布于 2019-03-31 03:44:36
问题是图片格式是.svg,将图标转换成.png效果很好!
https://stackoverflow.com/questions/55427565
复制相似问题