2023-02-10 记录一下rn 图标使用方法(转载)
我原本以为react-native的button有官方写好的icon可以使用,但没曾想没有,而且还没有官方出的icon,故此得寻找第三方插件:react-native-vector-icons
插件地址:https://oblador.github.io/react-native-vector-icons/
Android:
安装:
npm install --save react-native-vector-icons
在android包里的app文件夹中找到build.gradle,并添加下面代码:
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
使用:
import AntDesign from 'react-native-vector-icons/AntDesign' ... ... <AntDesign name="upcircleo" size={100} color="green" />
安卓这边我试了没问题,ios的没有测。
Ios:
1、npm install --save react-native-vector-icons
2、复制 npm 上 react-native-vector-icons 上的 List of all available fonts to copy & paste in info.plist
<key>UIAppFonts</key> <array> <string>AntDesign.ttf</string> <string>Entypo.ttf</string> <string>EvilIcons.ttf</string> <string>Feather.ttf</string> <string>FontAwesome.ttf</string> <string>FontAwesome5_Brands.ttf</string> <string>FontAwesome5_Regular.ttf</string> <string>FontAwesome5_Solid.ttf</string> <string>Foundation.ttf</string> <string>Ionicons.ttf</string> <string>MaterialIcons.ttf</string> <string>MaterialCommunityIcons.ttf</string> <string>SimpleLineIcons.ttf</string> <string>Octicons.ttf</string> <string>Zocial.ttf</string> </array>
3、打开项目中的 ios 包中的 nativeApp
4、把 info.plist 在编辑器打开 内容是按照 key - value 保存的,把以上复制的内容按照 key - value 的格式粘贴到 dict 字典里面
5、cd 到 ios 包下
6、执行 pod install
7、cd …/
8、npm run ios
注:本文转载于https://blog.csdn.net/weixin_44691775/article/details/104406405
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)