RegAlertView.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // RegAlertView.m
  3. // yunbaolive
  4. //
  5. // Created by YB007 on 2020/4/29.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "RegAlertView.h"
  9. #import "PubH5.h"
  10. @implementation RegAlertView
  11. +(instancetype)showRegAler:(NSDictionary *)dataDic complete:(RegAlertBlock)complete;{
  12. RegAlertView *regView = [[[NSBundle mainBundle]loadNibNamed:@"RegAlertView" owner:nil options:nil]objectAtIndex:0];
  13. regView.regAlertEvent = complete;
  14. [regView setupView:dataDic];
  15. return regView;
  16. }
  17. -(void)setupView:(NSDictionary *)dataDic {
  18. [_agreeBtn setTitle:YZMsg(@"同意") forState:0];
  19. [_notAgreeBtn setTitle:YZMsg(@"暂不使用") forState:0];
  20. self.frame = CGRectMake(0, 0, _window_width, _window_height);
  21. self.backgroundColor = RGB_COLOR(@"#000000", 0.4);
  22. [[YBBaseAppDelegate sharedAppDelegate].topViewController.view addSubview:self];
  23. _titleL.text = minstr([dataDic valueForKey:@"title"]);
  24. _contentL.text = minstr([dataDic valueForKey:@"content"]);
  25. _contentL.textColor = RGB_COLOR(@"#323232", 1);
  26. _contentL.font = SYS_Font(15);
  27. _contentL.numberOfLines = 0;
  28. NSArray *ppA = [NSArray arrayWithArray:[dataDic valueForKey:@"message"]];
  29. NSMutableAttributedString *textAtt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",_contentL.text]];
  30. [textAtt addAttribute:NSForegroundColorAttributeName value:RGB_COLOR(@"#323232", 1) range:textAtt.yy_rangeOfAll];
  31. for (int i=0; i<ppA.count; i++) {
  32. NSDictionary *subDic = ppA[i];
  33. NSRange clickRange = [[textAtt string]rangeOfString:minstr([subDic valueForKey:@"title"])];
  34. [textAtt yy_setTextHighlightRange:clickRange color:Pink_Cor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  35. NSLog(@"协议");
  36. if ([PublicObj checkNull:minstr([subDic valueForKey:@"url"])]) {
  37. [MBProgressHUD showError:YZMsg(@"链接不存在")];
  38. return;
  39. }
  40. PubH5 *h5vc = [[PubH5 alloc]init];
  41. h5vc.url = minstr([subDic valueForKey:@"url"]);;
  42. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:h5vc animated:YES];
  43. }];
  44. }
  45. _contentL.attributedText = textAtt;
  46. }
  47. -(void)dismissView {
  48. [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  49. [self removeFromSuperview];
  50. }
  51. - (IBAction)clickCancleBtn:(id)sender {
  52. [self dismissView];
  53. if (self.regAlertEvent) {
  54. self.regAlertEvent(-1);
  55. }
  56. }
  57. - (IBAction)clickSureBtn:(id)sender {
  58. [self dismissView];
  59. if (self.regAlertEvent) {
  60. self.regAlertEvent(0);
  61. }
  62. }
  63. @end