// // YOUPAILZChatRoomGameCenterWindow.m // MSYOUPAI // // Created by CY on 2021/12/30. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAILZChatRoomGameCenterWindow.h" @interface YOUPAILZChatRoomGameCenterWindow () @end @implementation YOUPAILZChatRoomGameCenterWindow - (void)viewDidLoad { [super viewDidLoad]; self.baseView.hidden = YES; [self youpaifinitUI]; } - (void)youpaifinitUI{ UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, self.youpaiftotalHeight)]; bgV.backgroundColor = HexColorFromRGB(0x2A2935); [self.view addSubview:bgV]; [bgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.offset(0.0f); make.height.offset(self.youpaiftotalHeight); }]; [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)]; NSInteger colCount = 4; for (NSInteger i = 0; i < self.youpaiplist.count; i ++) { NSInteger col = i % colCount; NSInteger row = i / colCount; CGFloat width = KScreenWidth / colCount; YOUPAILCBannerModel *model = self.youpaiplist[i]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(col * width, row * 80.0f + 12.5f, width, 70.0f); btn.tag = i; [btn addTarget:self action:@selector(youpaifbtnClick:) forControlEvents:UIControlEventTouchUpInside]; [bgV addSubview:btn]; UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake((width - 50) / 2.0f, 0, 50, 50)]; [imageV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipimage]]; [btn addSubview:imageV]; UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, imageV.mj_h + 6.0f, btn.mj_w, btn.mj_h - (imageV.mj_h + 6.0f))]; lab.font = LCFont(11.0f); lab.textColor = HexColorFromRGB(0x9F9DA5); lab.textAlignment = NSTextAlignmentCenter; lab.text = model.youpaiptitle; [btn addSubview:lab]; } } - (void)youpaifbtnClick:(UIButton *)sender{ // sender.selected = !sender.selected; // NSDictionary *dict = self.youpaipdataSource[sender.tag]; // UIImageView *imageV = [sender viewWithTag:8888]; // UILabel *lab = [sender viewWithTag:9999]; // if (sender.selected) { // imageV.image = dict[@"selImage"]; // lab.text = dict[@"selTitle"]; // }else{ // imageV.image = dict[@"image"]; // lab.text = dict[@"title"]; // } // [self dismissViewControllerAnimated:YES completion:^{ if (self.youpaipitemClickBlock != nil) { self.youpaipitemClickBlock(self.youpaiplist[sender.tag]); } }]; } - (CGFloat)youpaiftotalHeight{ CGFloat totalHeight = 0.0f; NSInteger row = (self.youpaiplist.count + 3) / 4; totalHeight += 80.0f * row; totalHeight += 12.5f + SafeHeight; return totalHeight; } @end