react-native-vector-icons使用

本文详细介绍了如何在React Native项目中使用react-native-vector-icons,包括安装配置步骤和实际使用的示例代码,帮助开发者轻松添加和展示图标。
摘要由CSDN通过智能技术生成

react-native-vector-icons使用

1、安装及配置

(1)使用 npm install react-native-vector-icons --save命令进行安装;

(2)在xcode中打开项目,将node_modules/react-native-vector-icons下Fonts文件夹拖入xcode中,选择“Add to targets”“Create groups”
添加Fonts文件夹

(3)在Info.plist文件中添加属性“Fonts provided by application”
Info.plist文件添加属性

2、使用

下面实现个简单例子,将icons库中的图片全部展示出来,具体代码如下:
Home.js

import React from 'react';
import {
    ScrollView,
    Button,
    View,
    Text,
    StyleSheet,
} from 'react-native';

import {StackNavigator} from 'react-navigation';

import Icon from 'react-native-vector-icons/FontAwesome';

class Home extends React.Component {
   

    static navigationOptions = {
        title: 'vector-icons',
        headerBackTitle: 'back'
    };

    render() {

        const items = [];
        items.push({name: 'facebook', title: 'Entypo'});
        items.push({name: 'facebook-f', title: 'EvilIcons'});
        items.push({name: 'twitter', title: 'FontAwesome', bgColor: '#0366d6'});
        items.push({name: 'github', title: 'Foundation', bgColor: '#0366d6'});
        items.push({name: 'google-plus', title: 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值