react-native-vector-icons在TabNavigator使用示例

安装配置react-navigation 

https://reactnavigation.org/docs/en/getting-started.html 

安装react-navigation 报错 EPERM: operation not permitted ?
 
cmd进入根目录
cd android
gradlew clean
回到根目录 cd../
重新操作下载或运行
 
安装配置react-native-vector-icons
https://www.npmjs.com/package/react-native-vector-icons
图标库
 https://oblador.github.io/react-native-vector-icons/
 

Icon 图标在安卓模拟器显示划线框?

https://www.npmjs.com/package/react-native-vector-icons#troubleshooting

示例代码:

import React, { Component } from 'react'
import {Text,View,Platform} from 'react-native'

import Icon from 'react-native-vector-icons/FontAwesome';
import {createAppContainer, createBottomTabNavigator } from 'react-navigation';

import ArticleScreen from './tabs/article/article'
// import ArticleContentScreen from './tabs/article/content'
import ImageScreen from './tabs/image/image'
import MusicScreen from './tabs/music/music'
import MapScreen from './tabs/map/map'

const AppContainer = createAppContainer(createBottomTabNavigator({
    Home:{
        screen:ArticleScreen,
        navigationOptions: {
            tabBarLabel: '知道',
            tabBarIcon: ({ tintColor, focused }) => (
              <Icon
                name='home'
                size={23}
                style={{ color: tintColor }}
              />
            ),
            tabBarOptions: {
                activeTintColor: 'tomato',
                inactiveTintColor: 'gray'
            }  
        }
           
    },
    Image:{
        screen:ImageScreen,
        navigationOptions:{
            tabBarLabel:'靓图',
            tabBarIcon:({tintColor,focused}) =>(
                <Icon
                    name='circle-o'
                    size={23}
                    style={{ color: tintColor }}
                />
            ),
            tabBarOptions: {
                activeTintColor: 'tomato',
                inactiveTintColor: 'gray'
            }
        }
        
    },
    Music:{
        screen:MusicScreen,
        navigationOptions:{
            tabBarLabel:'音乐',
            tabBarIcon:({tintColor,focused}) =>(
                <Icon
                    name= 'music'
                    size={23}
                    style={{ color: tintColor }}
                />
            ),
            tabBarOptions: {
                activeTintColor: 'tomato',
                inactiveTintColor: 'gray'
            }
        }
        
    },
    Map:{
        screen:MapScreen,
        navigationOptions:{
            tabBarLabel:'地图',
            tabBarIcon:({tintColor,focused}) =>(
                <Icon
                    name= 'map-marker'
                    size={23}
                    style={{ color: tintColor }}
                />
            ),
            tabBarOptions: {
                activeTintColor: 'tomato',
                inactiveTintColor: 'gray'
            }
        }
        
    }
}));
export default class Router extends Component {
    render() {
        return <AppContainer />
    }

}

效果图

 

转载于:https://www.cnblogs.com/eddina/p/10156829.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值