1.安装

yarn add react-navigation react-native-vector-icons

2.创建 root.js

import React, {Component} from 'react';
import {createStackNavigator} from 'react-navigation'
import Tab from './scene/Web/ButtomTab'
import login from './scene/login'
import Positioning from "./scene/Home/Positioning";
import Jump from "./scene/Home/Jump"; type Props = {}; export default class root extends Component<Props> {
render() {
return (
<HomeStack/>
);
}
} const HomeStack = createStackNavigator({
//底部导航页面
Homes: {
screen: Tab,
navigationOptions: {
header: null //顶部导航很多都会自己自定义,这里就为空
}
},
//登录页面
login: {
screen: login,
},
//定位
Positioning: {
screen: Positioning,
navigationOptions: {
header: null //顶部导航很多都会自己自定义,这里就为空
}
},
//测试跳页的页面
Jump: {
screen: Jump,
navigationOptions: {
title: '选择定位'
} }
}, {
//默认出现的首页页面
initialRouteName: 'Homes'
});

代码中有注释,代表的意思,进入到根后到createStackNavigator,默认输出的家园中到选项卡的底部标签,跳转接着到

接着上标签里出现到createButtomNavigator导航到代码

3.创建 底部选项卡

import React, {Component} from 'react';
import {
StyleSheet,
Dimensions,
Platform
} from 'react-native';
import color from './Color' //颜色样式
import Memo from "../Memo/Memo";
import Ionicons from 'react-native-vector-icons/Ionicons'
import Statistics from "../Statistics/Statistics";
import {createBottomTabNavigator} from "react-navigation";
import Home from "../Home/Home";
import My from "../My/My" export default Tab = createBottomTabNavigator({
Home: {
screen: Home,
navigationOptions: {
tabBarPosition: 'bottom',
tabBarLabel: '首页',
showLabel:false,
tabBarIcon: ({tintColor, focused}) => (
<Ionicons
name={focused ? 'ios-home' : 'ios-home-outline'}
size={26}
style={{color: tintColor}}
/>
),
}
},
Memorandum: {
screen: Memo,
navigationOptions: {
tabBarPosition: 'bottom',
tabBarLabel: '备忘',
tabBarIcon: ({tintColor, focused}) => (
<Ionicons
name={focused ? 'ios-paper' : 'ios-paper-outline'}
size={26}
style={{color: tintColor}}
/>
),
}
},
Statistics: {
screen: Statistics,
navigationOptions: {
tabBarLabel: '统计',
tabBarPosition: 'bottom',
tabBarIcon: ({tintColor, focused}) => (
<Ionicons
name={focused ? 'ios-stats' : 'ios-stats-outline'}
size={26}
style={{color: tintColor}}
/>
),
}
},
My: {
screen: My,
navigationOptions: {
tabBarLabel: '我的',
tabBarPosition: 'bottom',
tabBarIcon: ({tintColor, focused}) => (
<Ionicons
name={focused ? 'ios-person' : 'ios-person-outline'}
size={26}
style={{color: tintColor}}
/>
),
}
}, }, {
tabBarOptions: {
activeTintColor: color.primary,
inactiveTintColor: color.gray,
},
animationEnabled: true,
swipeEnabled: false,
//是否可以滑动切换
swipeEnabled: true,
//切换是否有动画
animationEnabled: true,
//进入App的首页面
initialRouteName: 'Home',
//对于导航的设置
tabBarOptions: {
//android特有下划线的颜色1
indicatorStyle: {height: 0},
//文字的样式
labelStyle: {
fontSize: 10
},
//对于导航的stytles
style :{
borderTopColor:'#ebebeb',
borderTopWidth:1,
backgroundColor:'white',
height:Dimensions.get('window').height*0.08,
}
}
});

颜色样式

export default {
primary: '#1E90FF', //主题样式 选中底部标题和图片的颜色以及顶部标题
border: '#e0e0e0',
paper: '#f3f3f3',
gray: '#979797', //灰色 未选中底部标题和图片的颜色1
background:'#F5FCFF',
white:'#FFFFFF',
titleBottonSolid: '#979797',
}

.

react-navigation + react-native-vector-icons的更多相关文章

  1. React Navigation & React Native & React Native Navigation

    React Navigation & React Native & React Native Navigation React Navigation https://facebook. ...

  2. React Navigation / React Native Navigation 多种类型的导航结合使用,构造合理回退栈

    React Navigation 更新到版本5已经是非常完善的一套导航管理组件, 提供了Stack , Tab , Drawer 导航方式 , 那么我们应该怎样设计和组合应用他们来构建一个完美的回退栈 ...

  3. React Native常用组件之TabBarIOS、TabBarIOS.Item组件、Navigator组件、NavigatorIOS组件、React Navigation第三方

    以下内容为老版本React Native,faceBook已经有了新的导航组件,请移步其他博客参考>>[我是传送门] 参考资料:React Navigation  react-native ...

  4. [RN] 04 - React Navigation

    react-navigation和react-router的对比: 支持的平台: react-navigation: react-native react-router: react-native.r ...

  5. React-native 导航插件React Navigation 4.x的使用

    React-native 导航插件React Navigation 4.x的使用 文档 英文水平可以的话,建议直接阅读英文文档 简单使用介绍 安装插件 yarn add react-navigatio ...

  6. 小谈React、React Native、React Web

    React有三个东西,React JS 前端Web框架,React Native 移动终端Hybrid框架,React Web是一个源码转换工具(React Native 转 Web,并之所以特别提出 ...

  7. React的React Native

    React的React Native React无疑是今年最火的前端框架,github上的star直逼30,000,基于React的React Native的star也直逼20,000.有了React ...

  8. react-native 学习 ----- React Navigation

    很久没有的登陆博客园了,密码都是找回的,从当年的大学生已经正常的走上了程序员的道路,看到之前发的博客还是写的android,现在自己已经在使用了react-native了. 大学毕业了,做了java后 ...

  9. react-native导航器 react navigation 介绍

    开发环境搭建好之后,想要进一步了解react-native,可以先从react-native官网上的电影列表案例入手: https://reactnative.cn/docs/0.51/sample- ...

  10. React 与 React Native 底层共识:React 是什么

    此系列文章将整合我的 React 视频教程与 React Native 书籍中的精华部分,给大家介绍 React 与 React Native 结合学习的方法,此小节主要介绍 React 的底层原理与 ...

随机推荐

  1. Android 系统启动过程详解

    android 使用 linux 内核,一般运行在 ARM 体系架构上,android 设备启动的过程,应用层之下基本等同于linux, 从应用层第一个程序init开始有所区别,下面开始介绍. ste ...

  2. VC无闪烁刷屏技术的实现【转】

    转自:http://blog.csdn.net/scorpio_tiger/article/details/2888719 http://www.pconline.com.cn/pcedu/empol ...

  3. request_mem_region 与 ioremap【转】

    转自:http://blog.csdn.net/alada007/article/details/7700125 如果从根本上说起的话应该从Intel的处理器芯片与其它的芯片的不同说起,与这两个函数相 ...

  4. spark streaming 异常No output streams registered, so nothing to execute

    实现spark streaming demo时,代码: public static void main (String[] args) { SparkConf conf = new SparkConf ...

  5. 关于CI框架加入sphinx官方API接口文件的时候,需要注意的问题

    从sphinx下载的官方文件sphinxapi.php中类名为class SphinxClient 加入到CI框架,放在system/libraries/下,由于需要遵从CI框架libraries类名 ...

  6. Appium+python自动化8-Appium Python API【转载】

    前言: Appium Python API全集,不知道哪个大神整理的,这里贴出来分享给大家. 1.contexts contexts(self): Returns the contexts withi ...

  7. tf一些理解(根据资料)

    首先看了开源操作机器人系统-ros这本书(张建伟)第五章slam导航 5.1使用tf配置机器人 还有ros navigation 教程 http://wiki.ros.org/navigation/T ...

  8. 使用Laravel将数据Excel导出的方法

    1.copmposer下载maatwebsite/excel 2.在控制器引入:use Excel; 3.将要导出的数据处理成数组,第一组数据为表的字段名,如图 4.导出成表格 Excel::crea ...

  9. 牛客网 牛客小白月赛5 I.区间 (interval)-线段树 or 差分数组?

    牛客小白月赛5 I.区间 (interval) 休闲的时候写的,但是写的心情有点挫,都是完全版线段树,我的一个队友直接就水过去了,为啥我的就超内存呢??? 试了一晚上,找出来了,多初始化了add标记数 ...

  10. c# await 到底等待的是什么?

    static void Main(string[] args) { Print(); Console.WriteLine("5 :::" + Thread.CurrentThrea ...