iOS微信分享后关闭发送成功提示并返回应用

 更新时间:2016年09月14日 11:56:18   投稿:lijiao  
这篇文章主要为大家详细介绍了iOS微信分享后关闭发送成功提示并返回应用的相关资料,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

iOS 分享到微信之后返回应用关闭发送成功的提示,并自定义提示,具体内容如下

1.关闭发送成功的提示 

只要在分享的时候调用一下代码即可:

复制代码 代码如下:
 [UMSocialConfig setFinishToastIsHidden:YES  position:UMSocialiToastPositionCenter]; 

2.自定义提示 

//如果点击返回app会调用这个方法
 - (void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response {
   //返回200说明分享成功 
  if (response.responseCode == 200) { 
      //分享成功之后弹出这个提示语 
 
      //自己添加遮罩层,并添加点击手势,方便回收提示 
      self.mask2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height)]; 
      self.mask2.backgroundColor = [[UIColor colorWithHexColorString:@"000000"] colorWithAlphaComponent:0.5]; 
      UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)]; 
      [self.mask2 addGestureRecognizer:tap]; 
      [self.view.window addSubview:self.mask2];
     //遮罩层上放提示框      
      self.showView = [[UIView alloc] 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 = [UIColor whiteColor]; 
      self.showView.layer.cornerRadius = 20; 
      [self.mask2 addSubview:_showView];
 
      
 
      UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _showView.width, 31)]; 
      titleLab.text = @"分享成功"; 
      titleLab.textAlignment = NSTextAlignmentCenter; 
      titleLab.backgroundColor = [UIColor redColor]; 
      titleLab.textColor = [UIColor whiteColor]; 
      titleLab.font = [UIFont systemFontOfSize:15]; 
     //使用贝塞尔曲线,绘制一个上面两个是圆角的矩形 
      UIBezierPath *titlePath = [UIBezierPath bezierPathWithRoundedRect:titleLab.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(20, 20)]; 
      CAShapeLayer *titleLayer = [CAShapeLayer layer]; 
      titleLayer.frame = titleLab.bounds; 
      titleLayer.path = titlePath.CGPath; 
      titleLab.layer.mask = titleLayer; 
      [_showView addSubview:titleLab]; 
 
      UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(16, 31+16, _showView.width-32, 15)]; 
      lab.textAlignment = NSTextAlignmentLeft;
       lab.text = @"大家都在看"; 
      lab.textColor = [UIColor colorWithHexColorString:@"000000"]; 
      lab.font = [UIFont systemFontOfSize:15]; 
      [_showView addSubview:lab];
 
      
 
      NSMutableArray *arr = [[NSMutableArray alloc] initWithObjects:@"",@"" nil]; 
      int y = 31+16+15+16; 
      for (int i = 0; i<arr.count; i++) {
 
        UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom]; 
        CGSize size = [self getStringSize:arr[i] andFont:13 andWidth:self.showView.width-32]; 
        button1.tag = 600+i; 
        button1.frame = CGRectMake(16, y, _showView.width-32, size.height); 
        [button1 setTitle:arr[i] forState:UIControlStateNormal]; 
        button1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; 
        [button1 setTitleColor:[UIColor colorWithHexColorString:@"0096ff"] forState:UIControlStateNormal]; 
        button1.titleLabel.font = [UIFont systemFontOfSize:13]; 
        [button1 addTarget:self action:@selector(button1Click:) forControlEvents:UIControlEventTouchUpInside]; 
        button1.titleLabel.numberOfLines = 0; 
        [_showView addSubview:button1]; 
        y+=size.height+16;
         if (i+1!=arr.count) { 
          UIView *line = [[UIView alloc] initWithFrame:CGRectMake(16, y, self.showView.width-32, 0.5)]; 
          line.backgroundColor = [UIColor colorWithHexColorString:@"f0f0f0"]; 
          [_showView addSubview: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{ 
    [MBProgressHUD showError:@"分享失败"]; 
  }
 
}
 
 
 
//获取字符串的长度 
-(CGSize)getStringSize:(NSString*)needString andFont:(CGFloat)font andWidth:(NSInteger)width
 
{ 
  CGSize size = CGSizeZero; 
  size = [needString boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]} context:nil].size; 
  return size; 
} 
//若点击在某个区域之内不触发,否则触发 
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { 
  if ([touch.view isDescendantOfView:self.showView]) { 
    return NO; 
  }else { 
    return YES 
    ; 
  } 
} 
- (void)tap:(UITapGestureRecognizer *)sender {
 
  [self.mask2 removeFromSuperview];
 
} 
- (void)button1Click:(UIButton *)sender { 
  [self.mask2 removeFromSuperview]; 
  switch (sender.tag) { 
    case 600: 
    {
     }
       break;
     case 601:
 
    { 
    } 
      break; 
    default: 
      break; 
  }
 
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • iOS Touch ID指纹识别技术简介

    iOS Touch ID指纹识别技术简介

    这篇文章主要为大家详细介绍了iOS Touch ID指纹识别技术,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2019-04-04
  • iOS 简约日历控件EBCalendarView的实现代码

    iOS 简约日历控件EBCalendarView的实现代码

    本篇文章主要介绍了iOS 简约日历控件EBCalendarView的实现代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-05-05
  • 谈谈iOS开发之JSON格式数据的生成与解析

    谈谈iOS开发之JSON格式数据的生成与解析

    JSON格式取代了xml给网络传输带来了很大的便利,本篇文章主要介绍了iOS开发:对象直接转化成JSON详解,具有一定的参考价值,有兴趣的可以了解一下。
    2017-01-01
  • iOS中将个别页面强制横屏其他页面竖屏

    iOS中将个别页面强制横屏其他页面竖屏

    这篇文章主要介绍了iOS中将个别页面强制横屏其他页面竖屏的实现思路,需要的朋友参考下吧
    2016-12-12
  • 详解Xcode 9 设置 iOS无线真机调试

    详解Xcode 9 设置 iOS无线真机调试

    本篇文章主要介绍了详解Xcode 9 设置 iOS无线真机调试,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-12-12
  • Xcode8打印一堆log问题的快速解决方法

    Xcode8打印一堆log问题的快速解决方法

    刚装的xcode8,不知道从哪来的一堆log,很奇怪。怎么解决此问题呢?下面小编给大家分享本教程帮助大家了解Xcode8打印一堆log问题的快速解决方法,感兴趣的朋友跟着小编一起学习吧
    2016-10-10
  • IOS添加自定义字体实例详解

    IOS添加自定义字体实例详解

    这篇文章主要介绍了IOS添加自定义字体实例详解的相关资料,需要的朋友可以参考下
    2017-04-04
  • iOS将视频录像切成一张张缩略图

    iOS将视频录像切成一张张缩略图

    这篇文章主要为大家详细介绍了iOS将视频录像切成一张张缩略图的相关代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-11-11
  • iOS两丫技术之UILabel性能不够的解决方法

    iOS两丫技术之UILabel性能不够的解决方法

    这篇文章主要介绍了iOS中控件UILabel性能不够而自定义UILabel的过程,UILable是iPhone界面最基本的控件,主要用来显示文本信息,下面通过本文我们来了解一下
    2022-08-08
  • iOS实现多个垂直滑动条并列视图

    iOS实现多个垂直滑动条并列视图

    这篇文章主要为大家详细介绍了iOS实现多个垂直滑动条并列视图,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-03-03

最新评论