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 的底层原理与 ...
随机推荐
- HDU 4649 Professor Tian (概率DP)
Professor Tian Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)To ...
- 限制MYSQL从服务器为只读状态
修改全局变量的方法有两种,第一种是修改配置文件,第二种是SQL语句设置全局变量的值.(可以参考:http://www.cnblogs.com/qlqwjy/p/8046592.html) 0.简介: ...
- 转载~基于比较的排序算法的最优下界为什么是O(nlogn)
基于比较的排序算法的最优下界为什么是O(nlogn) 发表于2013/12/21 16:15:50 1024人阅读 分类: Algorithm 1.决策二叉树 回答这个问题之前我们先来玩一个猜数字的 ...
- linux下如何实现简单刷屏【转】
转自:http://blog.csdn.net/figthter_cui/article/details/6145272 版权声明:本文为博主原创文章,未经博主允许不得转载. 今天为了测试我的LCD有 ...
- (二十)linux中i2c的ioctl,write,read函数的使用
一.ioctl函数的使用:原型:struct ioctl(struct file *file,unsigned int cmd,unsigned long arg);cmd有I2C_SLAVE,I2C ...
- 信号槽库:sigslot.h和sigc++使用
用qt的知道,qt有方便简单的信号槽机制,但需要专门的qt工具处理. 如果想直接使信号槽就可以使用sigslot库,或者sigc++库,或者boost中的signals,这里介绍sigslot和sig ...
- 前端知识学习——html
<!-- Html,CSS,JS 三者的关系 ==> 人,衣服,动作. 以下展示 html 常用基本编码 --><!-- Html 在PyCharm中新建html文件默认给出的 ...
- HDU 1698.Just a Hook-线段树(成段替换、输出总和tree[1])
HDU1698.Just a Hook 这个题是最最基础的成段更新的线段数的题目,直接贴代码吧. 代码: #include<iostream> #include<cstring> ...
- Codeforces Round #299 (Div. 2) B. Tavas and SaDDas【DFS/*进制思维/位运算/一个数为幸运数,当且仅当它的每一位要么是4,要么是7 ,求小于等于n的幸运数个数】
B. Tavas and SaDDas time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Python的程序结构[2] -> 类/Class[3] -> 内建类与内建函数
内建类与内建函数的区分 / Distinction of Built-in Type and Function 对于 Python,有许多可以不需要定义或引用就可以使用的函数(类)(参考内建模块),诸 ...