reactnative使用iconfont生成iconfont.
2023-05-18 本文已影响0人
勤的空间
sublime查找替换
查找:
[\s\S]*?"font_class": "(.+)",[\s\S]*?"unicode_decimal": (.+)[\s\S]*?}
替换
"$1": $2,\n
index.js
import createIconSet from 'react-native-vector-icons/lib/create-icon-set';
import glyphMap from './iconfont.json';
const iconSet = createIconSet(glyphMap, 'iconfont', 'iconfont.ttf');
export default iconSet;
export const {Button, getImageSource, getImageSourceSync} = iconSet;
使用
import {registerCustomIconType} from '@rneui/themed';
const iconSet = require('./iconfont/index.js').default;
registerCustomIconType('iconfont', iconSet);
<Icon name="wode" type="iconfont" />