美文网首页
reactnative使用iconfont生成iconfont.

reactnative使用iconfont生成iconfont.

作者: 勤的空间 | 来源:发表于2023-05-18 11:40 被阅读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" />

相关文章

网友评论

      本文标题:reactnative使用iconfont生成iconfont.

      本文链接:https://www.haomeiwen.com/subject/imdijdtx.html