欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

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

程序员文章站 2023-12-14 22:44:28
ios 分享到微信之后返回应用关闭发送成功的提示,并自定义提示,具体内容如下 1.关闭发送成功的提示  只要在分享的时候调用一下代码即可: 复制代码...

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; 
  }
 
}

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

上一篇:

下一篇: