yarn add react-native-vector-icons
在node_modules里找到react-native-vector-icons->Fonts->拷贝所有ttf文件放置到->android->app->src->main->assets->fonts文件夹内
如无则创建
修改android->app->build.gradle
在首行添加
apply from:"../../node_modules/react-native-vector-icons/fonts.gradle"
导入
import xx from 'react-native-vector-icons/FontAwesome'
使用
<xx name='图标名称' size={数值} color='颜色'/>
阿里图标使用:
图标
代码示例:
import React,{Component} from 'react'
import {View,Text,StyleSheet} from 'react-native'
import FontAwesome from 'react-native-vector-icons/FontAwesome'
export default class App extends Component{
render(){
return(
<>
<FontAwesome name="rocket" size={30} color="#900"/>
{/* <Text>hh</Text> */}
</>
)
}
}