标签:ret main image home 逗号 manager 更换 nat reac
npm install --save react-native-vector-icons
推荐在RN项目中使用yarn安装包依赖
yarn add react-native-vector-icons
project.ext.vectoricons = [
iconFontNames: [ ‘MaterialIcons.ttf‘, ‘EvilIcons.ttf‘ ,‘FontAwesome.ttf‘] // 这里就是你要使用的图标库,根据需要做调整
//我主要用的是FontAwesome.ttf,所以就在后面加上了这个
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
Fonts
文件夹中的所有内容复制到 android/app/src/main/assets/fonts 文件夹中,assets和fonts可能没有这两个文件夹,那就自己手动建,注意文件夹名全为小写
复制到刚才建好的文件夹中
rootProject.name = ‘MyApp‘
include ‘:app‘
+ include ‘:react-native-vector-icons‘
+ project(‘:react-native-vector-icons‘).projectDir = new File(rootProject.projectDir, ‘../node_modules/react-native-vector-icons/android‘)
apply plugin: ‘com.android.application‘
android {
...
}
dependencies {
compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
+ compile project(‘:react-native-vector-icons‘)
}
package com.myapp;
+ import com.oblador.vectoricons.VectorIconsPackage;
....
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
+ , new VectorIconsPackage() //注意 这里有逗号,不要少复制了
);
}
}
//导入图标相关组件
import Icon from ‘react-native-vector-icons/FontAwesome‘
<Icon name="home" size={25} color=‘black‘ /> //更换name的值,使用不同的图标
react-native-vector-icons的使用说明
标签:ret main image home 逗号 manager 更换 nat reac
原文地址:https://www.cnblogs.com/zqblog1314/p/13061316.html