// // QXUserInfoGiftWallView.m // QXLive // // Created by 启星 on 2025/7/7. // #import "QXUserInfoGiftWallView.h" @interface QXUserInfoGiftWallView() @property (nonatomic,strong)UIView *bgView; @property (nonatomic,strong)UIImageView *bgImageView; @property (nonatomic,strong)UIButton *alreadyBtn; @property (nonatomic,strong)UIButton *noBtn; @property (nonatomic,strong)UICollectionView *collectionView; @property (nonatomic,strong)NSMutableArray *dataArray; @end @implementation QXUserInfoGiftWallView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubviews]; } return self; } -(void)initSubviews{ self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)]; tap.delegate = self; [self addGestureRecognizer:tap]; self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, kSafeAreaBottom+ScaleWidth(429+33))]; // self.bgView.backgroundColor = [UIColor whiteColor]; [self addSubview:self.bgView]; self.bgImageView = [[UIImageView alloc] initWithFrame:self.bgView.bounds]; self.bgImageView.image = [UIImage imageNamed:@"room_user_bg"]; [self.bgView addSubview:self.bgImageView]; [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(ScaleWidth(24)); make.left.right.bottom.equalTo(self.bgView); }]; self.alreadyBtn = [[UIButton alloc] init]; [self.alreadyBtn setTitle:@"已点亮" forState:(UIControlStateNormal)]; [self.alreadyBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateSelected)]; [self.alreadyBtn setTitleColor:RGB16A(0xffffff, 0.4) forState:(UIControlStateNormal)]; self.alreadyBtn.titleLabel.font = [UIFont systemFontOfSize:12]; [self.alreadyBtn setBackgroundImage:[UIImage imageWithColor:RGB16(0x8A72BE)] forState:(UIControlStateSelected)]; [self.alreadyBtn setBackgroundImage:[UIImage imageWithColor:RGB16(0x3C276A)] forState:(UIControlStateNormal)]; [self addSubview:self.alreadyBtn]; self.alreadyBtn.selected = YES; [self.alreadyBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(16); make.top.equalTo(self).offset(20); make.height.mas_equalTo(ScaleWidth(22)); make.width.mas_equalTo(ScaleWidth(28)); }]; self.noBtn = [[UIButton alloc] init]; [self.noBtn setTitle:@"未点亮" forState:(UIControlStateNormal)]; [self.noBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateSelected)]; [self.noBtn setTitleColor:RGB16A(0xffffff, 0.4) forState:(UIControlStateNormal)]; self.noBtn.titleLabel.font = [UIFont systemFontOfSize:12]; [self.noBtn setBackgroundImage:[UIImage imageWithColor:RGB16(0x8A72BE)] forState:(UIControlStateSelected)]; [self.noBtn setBackgroundImage:[UIImage imageWithColor:RGB16(0x3C276A)] forState:(UIControlStateNormal)]; [self addSubview:self.noBtn]; [self.noBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.alreadyBtn.mas_right).offset(12); make.top.equalTo(self).offset(20); make.height.mas_equalTo(ScaleWidth(22)); make.width.mas_equalTo(ScaleWidth(28)); }]; UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake((SCREEN_WIDTH-16*2-10*2)/3, ScaleWidth(149)); layout.minimumLineSpacing = 10; layout.minimumInteritemSpacing = 10; layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16); layout.scrollDirection = UICollectionViewScrollDirectionVertical; self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; [self.collectionView registerClass:[QXUserInfoGiftWallCell class] forCellWithReuseIdentifier:@"QXUserInfoGiftWallCell"]; self.collectionView.delegate = self; self.collectionView.dataSource = self; self.collectionView.showsHorizontalScrollIndicator = NO; self.collectionView.bounces = NO; self.collectionView.pagingEnabled = YES; self.collectionView.backgroundColor = RGB16(0xf6f6f6); [self addSubview:self.collectionView]; [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(12); make.top.equalTo(self.alreadyBtn.mas_bottom).offset(22); make.height.mas_equalTo(ScaleWidth(76)); make.right.mas_equalTo(-12); }]; } -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ return touch.view == self; } #pragma mark - UITableViewDataSource, UITableViewDelegate -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return self.dataArray.count; } -(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ QXUserInfoGiftWallCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXUserInfoGiftWallCell" forIndexPath:indexPath]; // cell.model = self.dataArray[indexPath.row]; return cell; } -(void)showInView:(UIView *)view{ [view addSubview:self]; [UIView animateWithDuration:0.3 animations:^{ self.bgView.y = SCREEN_HEIGHT- ScaleWidth(429+33)-kSafeAreaBottom; }]; } -(void)hide{ [UIView animateWithDuration:0.3 animations:^{ self.bgView.y = SCREEN_HEIGHT; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; } -(NSMutableArray *)dataArray{ if (!_dataArray) { _dataArray = [NSMutableArray array]; } return _dataArray; } @end @implementation QXUserInfoGiftWallCell - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubviews]; } return self; } -(void)initSubviews{ self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_giftwall_gray"]]; [self.contentView addSubview:self.bgImageView]; [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.right.bottom.equalTo(self); }]; self.giftImageView = [[UIImageView alloc] init]; self.giftImageView.contentMode = UIViewContentModeScaleAspectFit; [self.contentView addSubview:self.giftImageView]; [self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(17); make.size.mas_equalTo(CGSizeMake(ScaleWidth(60), ScaleWidth(60))); make.centerX.equalTo(self); }]; self.giftNameLabel = [[UILabel alloc] init]; self.giftNameLabel.textColor = UIColor.whiteColor; self.giftNameLabel.textAlignment = NSTextAlignmentCenter; self.giftNameLabel.font = [UIFont systemFontOfSize:12]; [self.contentView addSubview:self.giftNameLabel]; [self.giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.giftNameLabel.mas_bottom).offset(1); make.height.mas_equalTo(18); make.left.right.equalTo(self); }]; self.giftCountLabel = [[UILabel alloc] init]; self.giftCountLabel.textColor = UIColor.whiteColor; self.giftCountLabel.textAlignment = NSTextAlignmentCenter; self.giftCountLabel.font = [UIFont systemFontOfSize:12]; [self.contentView addSubview:self.giftCountLabel]; [self.giftCountLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.giftNameLabel.mas_bottom).offset(1); make.height.mas_equalTo(18); make.left.right.equalTo(self); }]; self.userImageView1 = [[UIImageView alloc] init]; self.userImageView1.contentMode = UIViewContentModeScaleAspectFill; [self.contentView addSubview:self.userImageView1]; [self.userImageView1 mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(18); make.bottom.equalTo(self).offset(-7); make.centerX.equalTo(self).offset(-9); }]; self.userImageView2 = [[UIImageView alloc] init]; self.userImageView2.contentMode = UIViewContentModeScaleAspectFill; [self.contentView addSubview:self.userImageView2]; [self.userImageView2 mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(18); make.bottom.equalTo(self).offset(-7); make.right.equalTo(self.userImageView1.mas_left).offset(-5); }]; self.userImageView3 = [[UIImageView alloc] init]; self.userImageView3.contentMode = UIViewContentModeScaleAspectFill; [self.contentView addSubview:self.userImageView3]; [self.userImageView3 mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(18); make.bottom.equalTo(self).offset(-7); make.right.equalTo(self.userImageView2.mas_left).offset(-5); }]; } @end