rn 图标库

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> */}
            </>
        )
    }
}
发布了619 篇原创文章 · 获赞 3 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_43294560/article/details/105194444
RN