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 的底层原理与 ...
随机推荐
- DotNETCore 学习笔记 Startup、中间件、静态文件
Application Startup Startup Constructor - IHostingEnvironment - ILoggerFactory ConfigureServices - I ...
- [ CodeVS冲杯之路 ] P3038
不充钱,你怎么AC? 题目:http://codevs.cn/problem/3038/ 按照题目给定的方法,一步步推下去,直到推到1就输出次数 至于-1的话,一开始想直接用数组判重,但是怕T掉,于是 ...
- [LeetCode] Combinations 回溯
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
- 转载~基于比较的排序算法的最优下界为什么是O(nlogn)
基于比较的排序算法的最优下界为什么是O(nlogn) 发表于2013/12/21 16:15:50 1024人阅读 分类: Algorithm 1.决策二叉树 回答这个问题之前我们先来玩一个猜数字的 ...
- 杭电oj2047-2049、2051-2053、2056、2058
2047 阿牛的EOF牛肉串 #include<stdio.h> int main(){ int n,i; _int64 s[]; while(~scanf("%d" ...
- 在 Flask 项目中解决 CSRF 攻击
#转载请留言联系 1. CSRF是什么? CSRF全拼为Cross Site Request Forgery,译为跨站请求伪造. CSRF指攻击者盗用了你的身份,以你的名义发送恶意请求.包括:以你名义 ...
- Selenium2+python自动化19-单选框和复选框(radiobox、checkbox)【转载】
本篇主要介绍单选框和复选框的操作 一.认识单选框和复选框 1.先认清楚单选框和复选框长什么样 2.各位小伙伴看清楚哦,上面的单选框是圆的:下图复选框是方的,这个是业界的标准,要是开发小伙伴把图标弄错了 ...
- failed to push some refs to 'git@github.com:laniu/liuna.git'报错原因
出现错误的主要原因是github中的README.md文件不在本地代码目录中 可以通过如下命令进行代码合并[注:pull=fetch+merge] git pull --rebase origin m ...
- 使用百度地图JavaScript实现驾车/公交/步行导航功能
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- Knockout 双向绑定的理解
今天做了个需求就是上传图片,然后在代码中通过jQuery给一个标签赋值,经过前台的debug,发现这个值赋值成功了,但是提交到后台的请求里就没了,然后经历了一顿度娘,结果中发现了问题. 既然knock ...