react-navigation + react-native-vector-icons
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的更多相关文章
- React Navigation & React Native & React Native Navigation
React Navigation & React Native & React Native Navigation React Navigation https://facebook. ...
- React Navigation / React Native Navigation 多种类型的导航结合使用,构造合理回退栈
React Navigation 更新到版本5已经是非常完善的一套导航管理组件, 提供了Stack , Tab , Drawer 导航方式 , 那么我们应该怎样设计和组合应用他们来构建一个完美的回退栈 ...
- React Native常用组件之TabBarIOS、TabBarIOS.Item组件、Navigator组件、NavigatorIOS组件、React Navigation第三方
以下内容为老版本React Native,faceBook已经有了新的导航组件,请移步其他博客参考>>[我是传送门] 参考资料:React Navigation react-native ...
- [RN] 04 - React Navigation
react-navigation和react-router的对比: 支持的平台: react-navigation: react-native react-router: react-native.r ...
- React-native 导航插件React Navigation 4.x的使用
React-native 导航插件React Navigation 4.x的使用 文档 英文水平可以的话,建议直接阅读英文文档 简单使用介绍 安装插件 yarn add react-navigatio ...
- 小谈React、React Native、React Web
React有三个东西,React JS 前端Web框架,React Native 移动终端Hybrid框架,React Web是一个源码转换工具(React Native 转 Web,并之所以特别提出 ...
- React的React Native
React的React Native React无疑是今年最火的前端框架,github上的star直逼30,000,基于React的React Native的star也直逼20,000.有了React ...
- react-native 学习 ----- React Navigation
很久没有的登陆博客园了,密码都是找回的,从当年的大学生已经正常的走上了程序员的道路,看到之前发的博客还是写的android,现在自己已经在使用了react-native了. 大学毕业了,做了java后 ...
- react-native导航器 react navigation 介绍
开发环境搭建好之后,想要进一步了解react-native,可以先从react-native官网上的电影列表案例入手: https://reactnative.cn/docs/0.51/sample- ...
- React 与 React Native 底层共识:React 是什么
此系列文章将整合我的 React 视频教程与 React Native 书籍中的精华部分,给大家介绍 React 与 React Native 结合学习的方法,此小节主要介绍 React 的底层原理与 ...
随机推荐
- [bzoj3122][SDOI2013]随机数生成器 ——BSGS,数列
题目大意 给定递推序列: F[i] = a*F[i-1] + b (mod c) 求一个最小的i使得F[i] == t 题解 我们首先要化简这个数列,作为一个学渣,我查阅了一些资料: http://d ...
- 用MysQL语句怎么进行远程连接数据库
一.连接远程数据库: 1.显示密码如:MySQL 连接远程数据库(192.168.2.115),端口“3306”,用户名为“root”,密码“root” C: -u root -proot (注意第一 ...
- 【原创】Linux环境下的图形系统和AMD R600显卡编程(9)——R600显卡的3D引擎和图形流水线
1. R600 3D引擎 R600核心是AMD一款非常重要的GPU核心,这个核心引入了统一处理器架构,其寄存器和指令集同以前的GPU 都完全不同,对其编程也有比较大的区别. 图1显示了R600 GPU ...
- Linux内核实践之tasklet机制【转】
转自:http://blog.csdn.net/bullbat/article/details/7423321 版权声明:本文为博主原创文章,未经博主允许不得转载. 作者:bullbat 源代码分析与 ...
- Webpack & The Hot Module Replacement热模块替换原理解析
Webpack & The Hot Module Replacement热模块替换原理解析 The Hot Module Replacement(HMR)俗称热模块替换.主要用来当代码产生变化 ...
- HTTP GET与POST区别
HTTP定义了与服务器交互的不同方法,最基本的方法是 GET 和 POST. HTTP-GET和HTTP-POST是使用HTTP的标准协议动词,用于编码和传送变量名/变量值对参数,并且使用相关的请求语 ...
- Daemon Process
Daemon Process 守护进程(Daemon)是运行在后台的一种特殊进程.它独立于控制终端并且周期性地执行某种任务或等待 处理某些发生的事件.守护进程是一种很有用的进程. Lin ...
- cp2102通过GPIO连接树莓派
此博客不在更新,我的博客新地址:www.liuquanhao.com ----------------------------------------------------------------- ...
- 解决Windows下网络原因Composer安装失败问题的方法
由于Composer镜像都在国外,所以直接在官网下载Windows Installer后安装很多情况下是无法成功安装的. 解决办法: 1,将php添加到系统环境变量,并开启openssl扩展. 2,点 ...
- ./configure时候遇到的问题 Cannot find install-sh, install.sh, or shtool in ac-aux
https://blog.csdn.net/anloan/article/details/17268997