react native Modal 使用详解
2017-05-08 15:59
791 查看
Modal 是可以覆盖在原生视图上。
属性:
animationType:显示和隐藏的动画
slide:从底部弹出
fade:渐隐渐显
none:无
onRequestClose:android 按返回键时回调。
onShow:modal显示时回调。
transparent:背景是否透明,默认为白色。
visible:是否显示。
github下载地址
属性:
animationType:显示和隐藏的动画
slide:从底部弹出
fade:渐隐渐显
none:无
onRequestClose:android 按返回键时回调。
onShow:modal显示时回调。
transparent:背景是否透明,默认为白色。
visible:是否显示。
/** * Created by on 2017/5/8. */ import React, {Component} from 'react'; import { StyleSheet, View, Modal, Button, Alert, } from 'react-native'; export default class ModalDemo extends Component { static navigationOptions = { title: 'Modal', }; state = { visible: false, transparent: true, } render() { return ( <View style={{flex:1}}> <Button title='显示Modal' onPress={()=>{this.setState({visible:true})}}/> <Modal visible={this.state.visible} transparent={this.state.transparent} onRequestClose={()=>{ Alert.alert("Modal has been closed."); }} onShow={()=>{ Alert.alert("Modal has been show."); }}> <View style={{flex:1,justifyContent:'center',alignItems:'center',backgroundColor:'rgba(0, 0, 0, 0.3)'}}> <View style={{height:200,width:275,backgroundColor:'white'}}> <Button title='关闭Modal' onPress={()=>{this.setState({visible:false})}}/> <Button title={this.state.transparent?'不透明':'透明'} onPress={()=>{this.setState({transparent:!this.state.transparent})}}/> </View> </View> </Modal> </View> ); } }
github下载地址
相关文章推荐
- React-Native 组件之 Modal的使用详解
- React-Native 组件之 Modal的使用详解
- react-native-router-flux 使用详解(三)
- react native SectionList 使用详解
- react native SegmentedControlIOS 使用详解
- react native DrawerLayoutAndroid 使用详解
- react-native-router-flux 使用详解(二)
- react native Button 使用详解
- react native TextInput 使用详解
- react native Switch使用详解
- react native RefreshControl 使用详解
- react_native_router_flux_使用详解(二)
- React Native之Redux使用详解之Actions(29)
- RN开源UI组件之react-native-button 使用详解
- react native Slider 使用详解
- react native ScrollView 使用详解
- RN开源UI组件之react-native-button 使用详解
- React Native按钮详解|Touchable系列组件使用详解
- react native Picker 使用详解
- react native DatePickerIOS 使用详解