我正在尝试添加自定义图标,我按照以下教程进行操作: https ://www.reactnative.guide/12-svg-icons-using-react-native-vector-icons/12.1-creating-custom-iconset.html
我将 icomoon.tff 文件放在 ./assets/fonts 中,所以在我的 package.json 中,我添加了:
"rnpm": {
"assets": [
"./assets/fonts"
]
},
然后在我的 HomePage.js 中:
import {createIconSetFromIcoMoon} from 'react-native-vector-icons';
import icoMoonConfig from '../selection.json';
const CustomIcon = createIconSetFromIcoMoon(icoMoonConfig);
CustomIcon.loadFont();
<CustomIcon name='aaa'
color = {color}
size = {size}
/>
然后我跑了:
yarn add react-native-vector-icons
yarn react-native link react-native-vector-icons
但是,它仍然显示无法识别的字体系列 Icomoon 并且屏幕显示一个问号而不是图标。