React Native 中使用图标

在React Native 中使用 react-native-vector-icons 插件,android 和 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

android 安装步骤:

  1. npm install --save react-native-vector-icons
  2. 在 android/app/build.gradle 的文件添加下面这句话 注意不是:android/build.gradle
    apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

接下来就可以使用 图标,到以下网址选图标
图标地址
https://oblador.github.io/react-native-vector-icons/

引入图标 要用谁的图标就引入谁的

import  AntDesign from 'react-native-vector-icons/AntDesign'
······
······
······
<AntDesign  name="upcircleo"  size={100} color="green" />

以上就是android 和 ios 使用图标的步骤啦
npm插件地址

喜欢可以点个赞哦,笔芯 ~

发布了12 篇原创文章 · 获赞 20 · 访问量 309

猜你喜欢

转载自blog.csdn.net/weixin_44691775/article/details/104406405