react native ActionSheetIOS 使用详解

ActionSheetIOS 有2个方法:
1、showActionSheetWithOptions(options: Object, callback: Function)

options:(字符串数组)按钮的标题(必选)
cancelButtonIndex:选项中取消按钮索引
destructiveButtonIndex:选项中删除按钮索引
title:顶部的标题
message:标题下方的信息

2、showShareActionSheetWithOptions(options: Object, failureCallback: Function, successCallback: Function)

message:要分享的信息
url:分享的URL地址
subject:分享的信息主题
excludedActivityTypes:在actionsheet中不显示的活动

/**
 * Created by![这里写图片描述](https://img-blog.csdn.net/20170523172118863?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWVuZ2tzMTk4Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast) on 2017/5/23.
 */
import React, {Component} from 'react';
import {
    StyleSheet,
    View,
    ActionSheetIOS,
    Button,
    Alert,
} from 'react-native';

export default class ActionSheetIOSDemo extends Component {

    _onPress = ()=>{
        ActionSheetIOS.showActionSheetWithOptions({
            options:['option1','option2','取消','删除'],
            cancelButtonIndex:2,
            destructiveButtonIndex:3,
            title:'title',
            message:'message',
        },(index)=>{
            Alert.alert('选中:'+index);
        })
    }

    _onPress1 = ()=>{
        ActionSheetIOS.showShareActionSheetWithOptions({
            message:'message',
            url:'http://blog.csdn.net/mengks1987',
            subject:'subject',
            title:'title',
            message:'message',
        },()=>{

        },()=>{

        })
    }

    render() {
        return (
            <View style={{flex:1}}>
                <Button title='弹出' onPress={this._onPress}/>
                <Button title='弹出分享' onPress={this._onPress1}/>
            </View>
        );
    }
}

这里写图片描述

github下载地址

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老孟Flutter

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值