你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS微信分享後封閉發送勝利提醒並前往運用

iOS微信分享後封閉發送勝利提醒並前往運用

編輯: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微信分享後封閉發送勝利提醒並前往運用】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved