YOUPAILZChatRoomGameCenterWindow.m 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // YOUPAILZChatRoomGameCenterWindow.m
  3. // MSYOUPAI
  4. //
  5. // Created by CY on 2021/12/30.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAILZChatRoomGameCenterWindow.h"
  9. @interface YOUPAILZChatRoomGameCenterWindow ()
  10. @end
  11. @implementation YOUPAILZChatRoomGameCenterWindow
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. self.baseView.hidden = YES;
  15. [self youpaifinitUI];
  16. }
  17. - (void)youpaifinitUI{
  18. UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, self.youpaiftotalHeight)];
  19. bgV.backgroundColor = HexColorFromRGB(0x2A2935);
  20. [self.view addSubview:bgV];
  21. [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  22. make.left.right.bottom.offset(0.0f);
  23. make.height.offset(self.youpaiftotalHeight);
  24. }];
  25. [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
  26. NSInteger colCount = 4;
  27. for (NSInteger i = 0; i < self.youpaiplist.count; i ++) {
  28. NSInteger col = i % colCount;
  29. NSInteger row = i / colCount;
  30. CGFloat width = KScreenWidth / colCount;
  31. YOUPAILCBannerModel *model = self.youpaiplist[i];
  32. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  33. btn.frame = CGRectMake(col * width, row * 80.0f + 12.5f, width, 70.0f);
  34. btn.tag = i;
  35. [btn addTarget:self action:@selector(youpaifbtnClick:) forControlEvents:UIControlEventTouchUpInside];
  36. [bgV addSubview:btn];
  37. UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake((width - 50) / 2.0f, 0, 50, 50)];
  38. [imageV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipimage]];
  39. [btn addSubview:imageV];
  40. UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, imageV.mj_h + 6.0f, btn.mj_w, btn.mj_h - (imageV.mj_h + 6.0f))];
  41. lab.font = LCFont(11.0f);
  42. lab.textColor = HexColorFromRGB(0x9F9DA5);
  43. lab.textAlignment = NSTextAlignmentCenter;
  44. lab.text = model.youpaiptitle;
  45. [btn addSubview:lab];
  46. }
  47. }
  48. - (void)youpaifbtnClick:(UIButton *)sender{
  49. // sender.selected = !sender.selected;
  50. // NSDictionary *dict = self.youpaipdataSource[sender.tag];
  51. // UIImageView *imageV = [sender viewWithTag:8888];
  52. // UILabel *lab = [sender viewWithTag:9999];
  53. // if (sender.selected) {
  54. // imageV.image = dict[@"selImage"];
  55. // lab.text = dict[@"selTitle"];
  56. // }else{
  57. // imageV.image = dict[@"image"];
  58. // lab.text = dict[@"title"];
  59. // }
  60. //
  61. [self dismissViewControllerAnimated:YES completion:^{
  62. if (self.youpaipitemClickBlock != nil) {
  63. self.youpaipitemClickBlock(self.youpaiplist[sender.tag]);
  64. }
  65. }];
  66. }
  67. - (CGFloat)youpaiftotalHeight{
  68. CGFloat totalHeight = 0.0f;
  69. NSInteger row = (self.youpaiplist.count + 3) / 4;
  70. totalHeight += 80.0f * row;
  71. totalHeight += 12.5f + SafeHeight;
  72. return totalHeight;
  73. }
  74. @end