模仿快捷分享、从下往上弹出窗口,自定义分享菜单

shareSDK快捷分享,有集成好的分享菜单栏,很方便好用但是只能是一种样式,总感觉很枯燥无味!我在集成的过程中还发现,快捷分享的成功失败很难拿到回调。所以下面介绍一种自定义的分享菜单以及对平台的定向分享,话不多说上代码,相信很容易看懂!

-(void)shareClick{

//****   从下往上弹出窗口   ******//

    shareview =[MyCtrol createViewWithFrame:CGRectMake(10, 0, Width-20, 150)];

    shareview.layer.cornerRadius=8;

    shareview.frame = CGRectMake(0, Height, Width, Height/2);

    [UIView animateWithDuration:.5 animations:^{

        shareview.frame = CGRectMake(10, Height-250, Width-20, 250);

    }];

    shareview.backgroundColor=[UIColor clearColor];

//****   从下往上弹出窗口   ******//


//****   各平台的分享菜单栏   ******//    

    UIView * topView =[MyCtrol createViewWithFrame:CGRectMake(0, 0, Width-20, 100)];

    topView.backgroundColor=[UIColor whiteColor];

    topView.layer.cornerRadius=8;

//****   各平台的分享菜单栏   ******// 


//****   取消弹出的分享菜单栏   ******//     

    UIButton *btn =[MyCtrol createBuuttonWithFrame:CGRectMake(0, 120, Width-20, 35) ImageName:nil Target:self Action:@selector(cancebtnlClick) Title:@"取消"];

    btn.layer.cornerRadius=8;

    btn.backgroundColor=[UIColor whiteColor];

//****   取消弹出的分享菜单栏   ******//  

    

    [shareview addSubview:btn];

    [shareview addSubview:topView];

    [BGview addSubview:shareview];


//****   编辑菜单栏对应平台logo以及点击事件触发的定向分享   ******//  

    NSArray *array =@[@"wechat@2x",@"pengyouquan@2x"];

    NSArray *array1 =@[@"微信",@"朋友圈"];


    for(int i =0 ;i<2 ;i++){

        UIButton *shareBtn = [MyCtrol createBuuttonWithFrame:CGRectMake(Width/7+Width/2.08*i, 10, Width/5.35, Width/5.35) ImageName:array[i] Target:self Action:@selector(sharebtnClick:) Title:nil];

        shareBtn.tag=100+i;

        UILabel *labtext =[MyCtrol createLabelWithFrame:CGRectMake(Width/7+Width/2.08*i, 80, Width/5.35, 20) Font:12 Text:array1[i]];

        labtext.textAlignment=1;

        [shareview addSubview:labtext];

        [shareview addSubview:shareBtn];

    }

//****   取消弹出的分享菜单栏   ******//      

}



-(void)cancebtnlClick{

    [shareview removeFromSuperview];

}

//********设置分享参数************

-(void)sharebtnClick:(UIButton *)btn{

    

    NSURL *url =[NSURL URLWithString:shareurl];

    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];

    [shareParams SSDKSetupShareParamsByText:@"凌猫停车扫码领券,分享有礼!"

                                     images:imgurl

                                        url:url

                                      title:@"凌猫扫码领券"

                                       type:SSDKContentTypeAuto];

    if(btn.tag==100){

       

        [self startSharePlatform:SSDKPlatformSubTypeWechatSession parameters:shareParams];

    }else if(btn.tag==101){

        [self startSharePlatform:SSDKPlatformSubTypeWechatTimeline parameters:shareParams];

    }

}

//********设置分享参数************


//********定向分享到对应平台(微信好友,朋友圈)************

-(void)startSharePlatform:(SSDKPlatformType)platform parameters:(NSMutableDictionary *)parameters{

    

    [ShareSDK share:platform parameters:parameters onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {

        

        switch (state) {

            case SSDKResponseStateSuccess:

            {

                [BGview removeFromSuperview];

                break;

            }

            case SSDKResponseStateCancel:

            {

               [BGview removeFromSuperview];

                break;

            }

            default:

                break;

        }

    }];

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值