模仿快捷分享、从下往上弹出窗口,自定义分享菜单
2017-07-11 18:14
555 查看
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{
[Sha
b59d
reSDK
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;
}
}];
}
-(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{
[Sha
b59d
reSDK
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;
}
}];
}
相关文章推荐
- 配置Info.plist (设置状态栏样式、自定义定位时系统弹出的提示语、配置3DTouch应用快捷菜单)
- ArcGIS API for Silverlight开发中鼠标左键点击地图上的点弹出窗口及右键点击弹出快捷菜单的实现代码
- Android手机UI设计---”知乎“界面外观模仿篇(二)---在Fragment里使用自定义listview以及popupwindow弹出窗口
- 安卓开发:自定义PopupWindow,实现模仿iOS底部弹出菜单
- JavaScript模仿MSN的弹出窗口FLASH
- 在word弹出的右键菜单中加上自定义的菜单项
- [转]ASP.NET1.1中关于验证控件和自定义弹出确认窗口的冲突问题
- SilverLight中弹出自定义模态窗口
- 访MSN浮出式窗口(2)--窗口区域和自定义绘制菜单
- 弹出自定义窗口
- 在FLEX中创建自定义弹出窗口
- 自定义网页右键弹出菜单
- 如何让javascript菜单点击时弹出新窗口
- web页面上 菜单弹出窗口 动态获取 数据
- 用open弹出窗口,可以实现无菜单,无工具栏..........
- 弹出自定义窗口
- JavaScript模仿MSN的弹出窗口FLASH
- 综合应用WPF/WCF/WF/LINQ之三十四:在XBAP项目中模拟弹出一个自定义的“模态窗口”
- 很好用的模态弹出窗口,可自定义弹出窗口外观
- 【转载】解决浏览器和discuz7.0论坛不兼容的方法,解决快捷回复弹出下载窗口的问题