react-native modal
1.属性
animationType(动画类型) PropTypes.oneOf([‘none’, ‘slide’, ‘fade’])
none:没有动画
slide:从底部滑入
fade:淡入视野
onRequestClose(被销毁时会调用此函数)Platform.OS ===’android’?PropTypes.func.isRequired:PropTypes.func
在 ‘Android’ 平台,必需使用此函数
onShow(模态显示的时候被调用)function
transparent (透明度) bool
true时,使用透明背景渲染模态。
visible(可见性) bool
决定模态是否可见
onOrientationChange(方向改变时调用)PropTypes.func
在模态方向变化时调用,提供的方向只是 ” 或 ”。在初始化渲染的时候也会调用,但是不考虑当前方向。
supportedOrientations(允许模态旋转到任何指定取向)PropTypes.arrayOf(PropTypes.oneOf([‘portrait’, ‘portrait-upside-down’, ‘landscape’,’landscape-left’,’landscape-right’]))
在iOS上,模态仍然受 info.plist 中的 UISupportedInterfaceOrientations字段中指定的限制。
2.modal 基本使用
export default class TestModal extends Component {
// 构造
constructor(props) {
super(props);
// 初始状态
this.state = {
isModal:false
};
}
showModal() {
this.setState({
isModal:true
})
}
onRequestClose() {
this.setState({
isModal:false
});
}
render() {
return(
<View style={styles.container}>
{/* 初始化Modal */}
<Modal
animationType='slide' // 从底部滑入
transparent={false} // 不透明
visible={this.state.isModal} // 根据isModal决定是否显示
onRequestClose={() => {this.onRequestClose()}} // android必须实现
>
<View style={styles.modalViewStyle}>
{/* 关闭页面 */}
<TouchableOpacity
onPress={() => {{
this.setState({
isModal:false
})
}}}
>
<Text>关闭页面</Text>
</TouchableOpacity>
</View>
</Modal>
{/* 返回按钮 */}
<TouchableOpacity
onPress={() => {{
this.props.navigator.pop()
}}}
>
<Text>返回</Text>
</TouchableOpacity>
{/* 模态跳转 */}
<TouchableOpacity
onPress={() => this.showModal()}
>
<Text>模态跳转</Text>
</TouchableOpacity>
</View>
);
}
}
3.modal 使用 —— 指示器
export default class TestModal extends Component {
// 构造
constructor(props) {
super(props);
// 初始状态
this.state = {
isModal:false
};
}
showModal() {
this.setState({
isModal:true
})
setTimeout(() => {
this.setState({
isModal:false
});
}, 1500)
}
onRequestClose() {
this.setState({
isModal:false
});
}
render() {
return(
<View style={styles.container}>
{/* 初始化Modal */}
<Modal
animationType='fade' // 淡入淡出
transparent={true} // 透明
visible={this.state.isModal} // 根据isModal决定是否显示
onRequestClose={() => {this.onRequestClose()}} // android必须实现
>
<View style={styles.modalViewStyle}>
<View style={styles.hudViewStyle}>
<ActivityIndicator style={styles.chrysanthemumStyle}></ActivityIndicator>
<Text style={styles.hudTextStyle}>加载中…</Text>
</View>
</View>
</Modal>
{/* 返回按钮 */}
<TouchableOpacity
onPress={() => {{
this.props.navigator.pop()
}}}
>
<Text>返回</Text>
</TouchableOpacity>
{/* 显示指示器 */}
<TouchableOpacity
onPress={() => this.showModal()}
>
<Text>显示指示器</Text>
</TouchableOpacity>
</View>
);
}
}
效果图

react-native modal的更多相关文章
- react native 入门实践
上周末开始接触react native,版本为0.37,边学边看写了个demo,语法使用es6/7和jsx.准备分享一下这个过程.之前没有native开发和react的使用经验,不对之处烦请指出.希望 ...
- [转] React Native Navigator — Navigating Like A Pro in React Native
There is a lot you can do with the React Native Navigator. Here, I will try to go over a few example ...
- 使用react native制作的一款网络音乐播放器
使用react native制作的一款网络音乐播放器 基于第三方库 react-native-video设计"react-native-video": "^1.0.0&q ...
- React Native 系列(八) -- 导航
前言 本系列是基于React Native版本号0.44.3写的.我们都知道,一个App不可能只有一个不变的界面,而是通过多个界面间的跳转来呈现不同的内容.那么这篇文章将介绍RN中的导航. 导航 什么 ...
- react native 中时间选择插件
npm install react-native-datepicker --save import DatePicker from 'react-native-datepicker'; <Vie ...
- React Native 0.50版本新功能简介
React Native在2017年经历了众多版本的迭代,从接触的0.29版本开始,到前不久发布的0.52版本,React Native作为目前最受欢迎的移动跨平台方案.虽然,目前存在着很多的功能和性 ...
- React Native (一) 入门实践
上周末开始接触react native,版本为0.37,边学边看写了个demo,语法使用es6/7和jsx.准备分享一下这个过程.之前没有native开发和react的使用经验,不对之处烦请指出.笔者 ...
- WEB通知和React Native之即时通讯(iOS Android)
WEB通知和React Native之即时通讯(iOS Android) 一,需求分析 1.1,允许服务器主动发送信息给客户端,客户端能监听到并且能接收. 1.2,为了方便同一个系统内的用户可以指定某 ...
- React Native——react-navigation的使用
在 React Native 中,官方已经推荐使用 react-navigation 来实现各个界面的跳转和不同板块的切换. react-navigation 主要包括三个组件: StackNavig ...
- beeshell —— 开源的 React Native 组件库
介绍 beeshell 是一个 React Native 应用的基础组件库,基于 0.53.3 版本,提供一整套开箱即用的高质量组件,包含 JavaScript(以下简称 JS)组件和复合组件(包含 ...
随机推荐
- bits,Bytes,KB,MB,GB和TB之间的换算关系
1Bytes=8bits(1字节等于8位) 1KB=1024Bytes(1KB等于1024字节) 1MB=1024KB 1GB=1024MB 1TB=1024GB 为啥带宽100M而下载大概只是12. ...
- [Codeforces 1246B] Power Products (STL+分解质因数)
[Codeforces 1246B] Power Products (STL+分解质因数) 题面 给出一个长度为\(n\)的序列\(a_i\)和常数k,求有多少个数对\((i,j)\)满足\(a_i ...
- Python环境配置:anaconda+pycharm一站式解决
https://www.cnblogs.com/yuxuefeng/p/9235431.html 不错的博文,码一下.
- Linux/Unix下pid文件作用浅析
转载:http://blog.csdn.net/changli_90/article/details/8911191 在Linux系统的目录/var/run下面一般我们都会看到很多的*.pid文件.而 ...
- HNUSTOJ 1444:树的最长路径
1444: 树的最长路径 时间限制: 1 Sec 内存限制: 128 MB 提交: 18 解决: 7 [提交][状态][讨论版] 题目描述 定义:无向树中结点的路径为该结点所能到达的最远距离:无向 ...
- MySQL---数据库切分
3.切分 水平切分 水平切分又称为sharding,它是将同一个表的记录拆分到多个结构相同的表中.当一个表的数据不断的增加的时候,sharding是必然的选择,它可以将数据分布到集群的不同节点上, ...
- GitHub入门使用
1.首先注册账号. 2.新建仓库. 3.安装GitBash 4.首先要在本地创建一个ssh key. $ ssh -keygen -t rsa -C "your email@.com&quo ...
- python中的Tkinter模块
Tkinter模块("Tk 接口")是Python的标准Tk GUI工具包的接口.Tk和Tkinter可以在大多数的Unix平台下使用,同样可以应用在Windows和Macinto ...
- Java设计模式之——代理设计模式
1.什么是代理设计模式 所谓代理模式是指客户端并不直接调用实际的对象,而是通过调用代理,来间接的调用实际的对象. 这里举一个栗子:就拿我们平时租房子来举例子,好比租客和房主之间的关系,我们租房子往往不 ...
- 使用vim打造python-ide
一.前言 一直希望在linux下进行python开发,但是linux不想启动图形化界面,所以干脆直接用上了万能的VIM,用VIM打造了属于自己的python-IDE 二.插件 标签导航(tagbar和 ...