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 的底层原理与 ...
随机推荐
- 全自动google检索后台
是不是每天为了找后台,伤破了蛋,每次在google输入”site:www.xxx.com intitle:登陆”.是不是手都累麻了,无聊又浪费时间.有了它,你的蛋就不用在碎了 直接上源码 1 2 3 ...
- 自定义topo遇到的坑
错误:TypeError: __init__() got an unexpected keyword argument 'delay' 解决办法:在创建topo的地方加一个link=TCLink即可, ...
- FileReader&FileWriter
FileReader public static void main(String[] args) { //创建文件对象指定要读取的文件路径 File file=new File("d:\\ ...
- 我从16ASPX上下了一个程序在运行时出错是怎么回事?运行时出现用户SA登陆失败,但是我已经把数据库导入SQL
如果你账号密码正确,那你可能没有打开你的管线服务,或者没有配置好你的客户端
- HDU 1394.Minimum Inversion Number-最小逆序数-完全版线段树(单点增减、区间求和)
HDU1394.Minimum Inversion Number 这个题求最小逆序数,先建一个空的树,然后每输入一个值,就先查询一下,查询之后,更新线段树,然后遍历一遍,每次将第一个数放到最后之后,减 ...
- UVA 11990 ”Dynamic“ Inversion(线段树+树状数组)
[题目链接] UVA11990 [题目大意] 给出一个数列,每次删去一个数,求一个数删去之前整个数列的逆序对数. [题解] 一开始可以用树状数组统计出现的逆序对数量 对于每个删去的数,我们可以用线段树 ...
- Linux下Shell的复制粘贴快捷键
[Shift]+[Insert]:复制 [Ctrl]+[Insert]:粘贴
- POJ 1511 Invitation Cards(单源最短路,优先队列优化的Dijkstra)
Invitation Cards Time Limit: 8000MS Memory Limit: 262144K Total Submissions: 16178 Accepted: 526 ...
- SQL Reverse函数
原文:SQL Reverse函数 Sql sever里面有个自带的reverse函数,这个函数的主要功能是把一个字符产反转.比如对于: select REVERSE('hello,world') 将得 ...
- android开发之自定义圆形ImagView
在日常使用中我们经常会使用到圆形的图片,但是android系统中并没有默认的圆形控件,所以我们需要自己来写一个自定义的ImagView来显示一张圆形的图片,下面先看效果 详细的方法是我们自定义一个类, ...