/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow

*npm:https://www.npmjs.com/package/react-native-drawer

*github:https://github.com/root-two/react-native-drawer

*/

import React, { Component } from 'react';
import Drawer from 'react-native-drawer'
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';

export default class demo extends Component {
closeControlPanel = () => {
this._drawer.close()
};
openControlPanel = () => {
this._drawer.open()
};
render() {
return (
<Drawer

side="top" //抽屉方向 top/left/right/bottom

open={false}//默认是否打开抽屉
tapToClose={true}//点击内容处 会关闭抽屉
type='displace' //抽屉出现的方式:overlay:抽屉覆盖内容 static:抽屉一只在内容后面 打开的时内容会滑动,displace:不会覆盖的 进出
openDrawerOffset={0.6} // 抽屉占整个屏幕的百分比(1-0.6=0.4)
closedDrawerOffset={0}//关闭抽屉后 抽屉在屏幕中的显示比例
styles={drawerStyles}//抽屉样式,背景色 透明度,阴影啥的
ref={(ref) => this._drawer = ref}
content={<View style={{flex:1,backgroundColor:'red'}}><Text onPress={()=>{this.closeControlPanel()}} style={{fontSize:100}}>抽屉的内容</Text></View>}
>
<View style={{flex:1,backgroundColor:'blue'}}><Text onPress={()=>{this.openControlPanel()}} style={{fontSize:30,}}>打开抽屉</Text></View>
</Drawer>
);
}
}

const drawerStyles = {
drawer: { flex:1,backgroundColor:'#000',shadowColor: '#0000ff', opacity: 0.6, shadowRadius: 3},
}

AppRegistry.registerComponent('demo', () => demo);

React Native 组建之IOS和Android通用抽屉的更多相关文章

  1. React Native之(支持iOS与Android)自定义单选按钮(RadioGroup,RadioButton)

    React Native之(支持iOS与Android)自定义单选按钮(RadioGroup,RadioButton) 一,需求与简单介绍 在开发项目时发现RN没有给提供RadioButton和Rad ...

  2. 封装 React Native 原生组件(iOS / Android)

    封装 React Native 原生组件(iOS / Android) 在 React Native中,有很多种丰富的组件了,例如 ScrollView.FlatList.SectionList.Bu ...

  3. 如何用 React Native 创建一个iOS APP?

    诚然,React Native 结合了 Web 应用和 Native 应用的优势,可以使用 JavaScript 来开发 iOS 和 Android 原生应用.在 JavaScript 中用 Reac ...

  4. 如何用 React Native 创建一个iOS APP?(三)

    前两部分,<如何用 React Native 创建一个iOS APP?>,<如何用 React Native 创建一个iOS APP (二)?>中,我们分别讲了用 React ...

  5. 如何用 React Native 创建一个iOS APP?(二)

    我们书接上文<如何用 React Native 创建一个iOS APP?>,继续来讲如何用 React Native 创建一个iOS APP.接下来,我们会涉及到很多控件. 1 AppRe ...

  6. React Native之通知栏消息提示(android)

    React Native之通知栏消息提示(android) 一,需求分析与概述 1.1,推送作为手机应用的基本功能,是手机应用的重要部分,如果自己实现一套推送系统费时费力,所以大部分的应用都会选择使用 ...

  7. React native 之设置IOS的图标,名称和启动图(下篇文章会讲到RN的android的相关设置)

    1.首先,app的名称: 如图所示:我的工程名叫BOOk 在BOOk下面的info.plist的文件里设置app的相关信息:比如Bundle name就是设置APP的名称 2.App的图标:(这里注意 ...

  8. React Native热更新(iOS)-Pushy

    React Native的出现,使的开发iOS代码出现了更便捷的方式.由于RN是使用脚本语言编写的,实现了"解释执行"的方式,而这种执行方式的修改只需替换脚步即可,不需要重新发布程 ...

  9. React Native项目集成iOS原生模块

    今天学习一下怎么在React Native项目中集成iOS原生模块,道理和在iOS原生项目中集成React Native模块类似.他们的界面跳转靠的都是iOS原生的UINavigationContro ...

随机推荐

  1. postgresql查询语句

    //查询表名称SELECT tablename FROM pg_tablesWHERE tablename NOT LIKE 'pg%'AND tablename NOT LIKE 'sql_%' O ...

  2. hibernate文档头的不同版本

    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "h ...

  3. JavaScript笔记 #06# Promise简单例子

    索引 回调版本 Promise版本1 Promise版本2 Notes 参考资料: Promise JavaScript Promise:简介 你去书店借书,按照异步的套路,剧情如下↓ 你:“老板,有 ...

  4. inst_for_mysql5.7.sh

    #!/bin/bash # Author: wangshenjin<wangshenjin233@foxmail.com> # Description: install percona-s ...

  5. MySQL修改库名的方法

    先创建新的库,再用RENAME TABLE 语句移动旧库中的表到新库,最后删除旧库. (root@localhost) [(none)] create database mydb_2; Query O ...

  6. centos7.3安装Nginx

    首先,如果是阿里云的centos的话,去阿里云管理端为80端口设置一组访问规则,因为阿里云默认是不开的 1. 添加Nginx yum 资源库 rpm -Uvh http://nginx.org/pac ...

  7. 观实验室PPT演讲有感

    outline 一定要有 说话的语速要慢,压制住紧张的心情 提前一天发布PPT dont` argue with audience, especially professor and teachers ...

  8. 数据库中char和varchar区别

    区别: 1)char长度是固定,而varchar长度是可变的: 比如:'abc'对于char(10)表示存储字符将占10个字节(包括7个空字符),而同样varchar(10)只占3个自己长度,10只是 ...

  9. linux homebrew skill 技巧

    $ cat /usr/bin/gitdiffH0#!/bin/bashgit diff HEAD $(git ls-files| grep '\.py$\|\.py\.in$') | osflake8 ...

  10. Item的anchors属性

    1.anchors group: anchors.top : AnchorLine anchors.bottom : AnchorLine anchors.left : AnchorLine anch ...