iOS微信分享后关闭发送成功提示并返回应用
iOS分享到微信之后返回应用关闭发送成功的提示,并自定义提示,具体内容如下
1.关闭发送成功的提示
只要在分享的时候调用一下代码即可:
[UMSocialConfigsetFinishToastIsHidden:YES position:UMSocialiToastPositionCenter];
2.自定义提示
//如果点击返回app会调用这个方法 -(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity*)response{ //返回200说明分享成功 if(response.responseCode==200){ //分享成功之后弹出这个提示语 //自己添加遮罩层,并添加点击手势,方便回收提示 self.mask2=[[UIViewalloc]initWithFrame:CGRectMake(0,0,kScreen_Width,kScreen_Height)]; self.mask2.backgroundColor=[[UIColorcolorWithHexColorString:@"000000"]colorWithAlphaComponent:0.5]; UITapGestureRecognizer*tap=[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tap:)]; [self.mask2addGestureRecognizer:tap]; [self.view.windowaddSubview:self.mask2]; //遮罩层上放提示框 self.showView=[[UIViewalloc]init]; self.showView.frame=CGRectMake(32,kScreen_Height/2.0-((kScreen_Width-64)/254.0*150.0+44)/2.0-20,kScreen_Width-64,0); self.showView.backgroundColor=[UIColorwhiteColor]; self.showView.layer.cornerRadius=20; [self.mask2addSubview:_showView]; UILabel*titleLab=[[UILabelalloc]initWithFrame:CGRectMake(0,0,_showView.width,31)]; titleLab.text=@"分享成功"; titleLab.textAlignment=NSTextAlignmentCenter; titleLab.backgroundColor=[UIColorredColor]; titleLab.textColor=[UIColorwhiteColor]; titleLab.font=[UIFontsystemFontOfSize:15]; //使用贝塞尔曲线,绘制一个上面两个是圆角的矩形 UIBezierPath*titlePath=[UIBezierPathbezierPathWithRoundedRect:titleLab.boundsbyRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRightcornerRadii:CGSizeMake(20,20)]; CAShapeLayer*titleLayer=[CAShapeLayerlayer]; titleLayer.frame=titleLab.bounds; titleLayer.path=titlePath.CGPath; titleLab.layer.mask=titleLayer; [_showViewaddSubview:titleLab]; UILabel*lab=[[UILabelalloc]initWithFrame:CGRectMake(16,31+16,_showView.width-32,15)]; lab.textAlignment=NSTextAlignmentLeft; lab.text=@"大家都在看"; lab.textColor=[UIColorcolorWithHexColorString:@"000000"]; lab.font=[UIFontsystemFontOfSize:15]; [_showViewaddSubview:lab]; NSMutableArray*arr=[[NSMutableArrayalloc]initWithObjects:@"",@""nil]; inty=31+16+15+16; for(inti=0;i<arr.count;i++){ UIButton*button1=[UIButtonbuttonWithType:UIButtonTypeCustom]; CGSizesize=[selfgetStringSize:arr[i]andFont:13andWidth:self.showView.width-32]; button1.tag=600+i; button1.frame=CGRectMake(16,y,_showView.width-32,size.height); [button1setTitle:arr[i]forState:UIControlStateNormal]; button1.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft; [button1setTitleColor:[UIColorcolorWithHexColorString:@"0096ff"]forState:UIControlStateNormal]; button1.titleLabel.font=[UIFontsystemFontOfSize:13]; [button1addTarget:selfaction:@selector(button1Click:)forControlEvents:UIControlEventTouchUpInside]; button1.titleLabel.numberOfLines=0; [_showViewaddSubview:button1]; y+=size.height+16; if(i+1!=arr.count){ UIView*line=[[UIViewalloc]initWithFrame:CGRectMake(16,y,self.showView.width-32,0.5)]; line.backgroundColor=[UIColorcolorWithHexColorString:@"f0f0f0"]; [_showViewaddSubview:line]; y+=0.5+16; } } self.showView.frame=CGRectMake(32,kScreen_Height/2.0-((kScreen_Width-64)/254.0*150.0+44)/2.0-20,kScreen_Width-64,y+16); }failure:^(AFHTTPRequestOperation*operation,NSError*error){ }]; }else{ [MBProgressHUDshowError:@"分享失败"]; } } //获取字符串的长度 -(CGSize)getStringSize:(NSString*)needStringandFont:(CGFloat)fontandWidth:(NSInteger)width { CGSizesize=CGSizeZero; size=[needStringboundingRectWithSize:CGSizeMake(width,CGFLOAT_MAX)options:NSStringDrawingUsesLineFragmentOriginattributes:@{NSFontAttributeName:[UIFontsystemFontOfSize:font]}context:nil].size; returnsize; } //若点击在某个区域之内不触发,否则触发 -(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizershouldReceiveTouch:(UITouch*)touch{ if([touch.viewisDescendantOfView:self.showView]){ returnNO; }else{ returnYES ; } } -(void)tap:(UITapGestureRecognizer*)sender{ [self.mask2removeFromSuperview]; } -(void)button1Click:(UIButton*)sender{ [self.mask2removeFromSuperview]; switch(sender.tag){ case600: { } break; case601: { } break; default: break; } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。