YBOtherCenterMore.m 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. //
  2. // YBOtherCenterMore.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2022/4/18.
  6. // Copyright © 2022 cat. All rights reserved.
  7. //
  8. #import "YBOtherCenterMore.h"
  9. @interface YBOtherCenterMore()<UIGestureRecognizerDelegate>
  10. @property(nonatomic,strong)UIView *bgView;
  11. @property(nonatomic,copy)OtherMoreBlock moreEvent;
  12. @property(nonatomic,strong)NSDictionary *dataDic;
  13. @end
  14. @implementation YBOtherCenterMore
  15. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch; {
  16. if ([touch.view isDescendantOfView:self.bgView]) {
  17. return NO;
  18. }
  19. return YES;
  20. }
  21. -(void)dissmissView {
  22. [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  23. [self removeFromSuperview];
  24. }
  25. +(instancetype)showOtherMoreWithBtns:(NSDictionary *)dataDic complete:(OtherMoreBlock)complete{
  26. YBOtherCenterMore *view = [[YBOtherCenterMore alloc]init];
  27. view.dataDic = dataDic;
  28. view.moreEvent = complete;
  29. view.frame = CGRectMake(0, 0, _window_width, _window_height);
  30. [[UIApplication sharedApplication].delegate.window addSubview:view];
  31. [view createUI];
  32. return view;
  33. }
  34. -(void)createUI {
  35. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dissmissView)];
  36. tap.delegate = self;
  37. [self addGestureRecognizer:tap];
  38. self.backgroundColor = RGB_COLOR(@"#000000", 0.5);;
  39. _bgView = [[UIView alloc]init];
  40. _bgView.backgroundColor = UIColor.whiteColor;
  41. _bgView.layer.cornerRadius = 10;
  42. _bgView.layer.masksToBounds = YES;
  43. [self addSubview:_bgView];
  44. [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.bottom.width.centerX.equalTo(self);
  46. }];
  47. //
  48. UILabel *titleL = [[UILabel alloc]init];
  49. titleL.font = SYS_Font(15);
  50. titleL.text = minstr([_dataDic valueForKey:@"name_str"]);
  51. titleL.textColor = RGB_COLOR(@"#323232", 1);
  52. [_bgView addSubview:titleL];
  53. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.equalTo(_bgView.mas_left).offset(20);
  55. make.right.lessThanOrEqualTo(_bgView.mas_right).offset(-20);
  56. make.top.equalTo(_bgView.mas_top).offset(25);
  57. }];
  58. //
  59. UILabel *idL = [[UILabel alloc]init];
  60. idL.font = SYS_Font(13);
  61. idL.text = minstr([_dataDic valueForKey:@"id_str"]);
  62. idL.textColor = RGB_COLOR(@"#7d7d7d", 1);
  63. [_bgView addSubview:idL];
  64. [idL mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.equalTo(titleL.mas_left);
  66. make.right.lessThanOrEqualTo(_bgView.mas_right).offset(-20);
  67. make.top.equalTo(titleL.mas_bottom).offset(5);
  68. }];
  69. //
  70. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  71. [closeBtn setImage:[UIImage imageNamed:@"个中-他人关闭"] forState:0];
  72. [closeBtn addTarget:self action:@selector(dissmissView) forControlEvents:UIControlEventTouchUpInside];
  73. [_bgView addSubview:closeBtn];
  74. [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.width.height.mas_equalTo(40);
  76. make.top.equalTo(_bgView.mas_top).offset(0);
  77. make.right.equalTo(_bgView.mas_right).offset(0);
  78. }];
  79. //funview
  80. NSArray *listA = @[
  81. @{@"title":@"私信",
  82. @"img":@"个中头更-私信",
  83. @"action":@(BtnFun_CenterImMsg),
  84. },
  85. @{@"title":@"举报",
  86. @"img":@"个中头更-举报",
  87. @"action":@(BtnFun_CenterReport),
  88. },
  89. @{@"title":minstr([_dataDic valueForKey:@"black_str"]),
  90. @"img":@"个中头更-拉黑",
  91. @"action":@(BtnFun_CenterBlack),
  92. },
  93. ];
  94. CGFloat itemSpace = 8;
  95. CGFloat itemW = (_window_width-40-itemSpace*(listA.count-1))/listA.count;
  96. UIView *boxView = [[UIView alloc]init];
  97. boxView.backgroundColor = UIColor.clearColor;
  98. [_bgView addSubview:boxView];
  99. [boxView mas_makeConstraints:^(MASConstraintMaker *make) {
  100. make.width.equalTo(_bgView.mas_width).offset(-40);
  101. make.centerX.equalTo(_bgView);
  102. make.top.equalTo(idL.mas_bottom).offset(20);
  103. make.height.mas_equalTo(70);
  104. make.bottom.equalTo(_bgView.mas_bottom).offset(-ShowDiff-30);
  105. }];
  106. MASViewAttribute *mas_left = boxView.mas_left;
  107. CGFloat realSpace = 0;
  108. for (int i = 0; i<listA.count; i++) {
  109. UIView *item = [[UIView alloc]init];
  110. item.backgroundColor = RGB_COLOR(@"#f4f4f4", 1);
  111. item.layer.cornerRadius = 5;
  112. item.layer.masksToBounds = YES;
  113. [boxView addSubview:item];
  114. [item mas_makeConstraints:^(MASConstraintMaker *make) {
  115. make.left.equalTo(mas_left).offset(realSpace);
  116. make.height.centerY.equalTo(boxView);
  117. make.width.mas_equalTo(itemW);
  118. }];
  119. realSpace = itemSpace;
  120. mas_left = item.mas_right;
  121. NSDictionary *subDic = listA[i];
  122. UIImageView *img = [[UIImageView alloc]init];
  123. img.image = [UIImage imageNamed:[subDic valueForKey:@"img"]];
  124. [item addSubview:img];
  125. [img mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.width.height.mas_equalTo(20);
  127. make.centerX.equalTo(item);
  128. make.bottom.equalTo(item.mas_centerY).offset(-2);
  129. }];
  130. UILabel *nameL = [[UILabel alloc]init];
  131. nameL.textColor = RGB_COLOR(@"#4F5259", 1);
  132. nameL.font = SYS_Font(12);
  133. nameL.text = YZMsg([subDic valueForKey:@"title"]);
  134. [item addSubview:nameL];
  135. [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  136. make.top.equalTo(item.mas_centerY).offset(2);
  137. make.centerX.equalTo(item);
  138. make.width.lessThanOrEqualTo(item);
  139. }];
  140. YBButton *shadowBtn = [YBButton buttonWithType:UIButtonTypeCustom];
  141. shadowBtn.btnFunStatus = [[subDic valueForKey:@"action"] integerValue];
  142. [shadowBtn addTarget:self action:@selector(clickShadownBtn:) forControlEvents:UIControlEventTouchUpInside];
  143. [item addSubview:shadowBtn];
  144. [shadowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.width.height.centerX.centerY.equalTo(item);
  146. }];
  147. }
  148. }
  149. -(void)clickShadownBtn:(YBButton *)sender {
  150. if (self.moreEvent) {
  151. self.moreEvent(sender.btnFunStatus);
  152. }
  153. [self dissmissView];
  154. }
  155. @end