React native 的弹出层(输入)效果


/*弹出层测试*/
import React,{Component} from 'react';
import {
  StyleSheet,
  View,
  Image,
  Text,
  TouchableOpacity,
  ScrollView,
  Navigator,
  Alert, //引入Alert组件
  TouchableHighlight,
  AlertIOS  //引入AlertIOS组件
} from 'react-native';
//创建一个组件
class CustomButton extends Component {
  render() {
    return (
      <TouchableHighlight    
        style={styles.button}
        underlayColor="red"   //触摸的时候颜色改变
        onPress={this.props.onPress}>  //当前触发时间
        <Text style={styles.buttonText}>{this.props.text}</Text>
      </TouchableHighlight>
    );
  }
}
//默认输出组件
export default class AlertDemo extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={{height:30,color:'black',margin:8}}>
          弹出框实例
        </Text>
        //触发事件
        <CustomButton text='点击弹出默认Alert'
          onPress={()=>Alert.alert('温馨提醒','确定退出吗?')}
          />
        <CustomButton text='点击弹出两个按钮的Alert'
          onPress={()=>Alert.alert('温馨提醒','确定退出吗?',[
            {text:'取消'},
            {text:'确定',}
            ])}
          />
        <CustomButton text='点击弹出三个按钮的Alert'
          onPress={()=>AlertIOS.alert('温馨提醒','确定退出吗?',[
            {text:'One'},
            {text:'Two'},
            {text:'Two'},
            {text:'Two'},
            {text:'Two'},
            {text:'Two'},
            {text:'Two'},
            {text:'Two'},
            {text:'Two'},
            {text:'Two'},
            {text:'Two'},
            {text:'Two'},
            ])}
          />
          <CustomButton text='点击出现输入框'
            onPress={()=>AlertIOS.prompt('温馨提醒','确定退出吗?',[
              {text:'取消'},
              {text:'确定',}
              ])}
            />
 
      </View>
    );
  }
}
 
 
 
var styles = StyleSheet.create({
  container:{
    backgroundColor:"#fff",
    flex:1,
    marginTop:65,
},
button: {
  margin:5,
  backgroundColor: 'white',
  padding: 15,
  borderBottomWidth: StyleSheet.hairlineWidth,
  borderBottomColor: '#cdcdcd',
}
 
 
})

 

转载于:https://my.oschina.net/allenxieyusheng/blog/731879

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值