Files
yuyin_ios/SweetParty/主类/音悦新增/酒吧厅&新人厅/YYRoomYinxiaoAlert.m
2025-08-08 11:05:33 +08:00

77 lines
2.3 KiB
Objective-C
Executable File

//
// YYRoomYinxiaoAlert.m
// YaYin
//
// Created by bj_szd on 2023/7/12.
// Copyright © 2023 YaYin. All rights reserved.
//
#import "YYRoomYinxiaoAlert.h"
#import "YYRoomYinxiaoCell.h"
@interface YYRoomYinxiaoAlert ()<UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@property (nonatomic, strong) NSArray *dataArray;
@end
@implementation YYRoomYinxiaoAlert
- (void)awakeFromNib {
[super awakeFromNib];
self.dataArray = @[@"笑声", @"欢呼", @"尴尬", @"掌声", @"么么哒"];
[self createUI];
}
- (void)createUI {
WEAK_SELF
[self.touchImgV dg_Tapped:^{
[weakSelf removeFromSuperview];
}];
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
CGFloat itemW = (ScreenWidth-30-10*4)/5;
layout.itemSize = CGSizeMake(itemW, 100);
layout.minimumInteritemSpacing = 10;
layout.minimumLineSpacing = 10;
layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_collectionView.collectionViewLayout = layout;
_collectionView.delegate = self;
_collectionView.dataSource = self;
[_collectionView registerNib:[UINib nibWithNibName:@"YYRoomYinxiaoCell" bundle:nil] forCellWithReuseIdentifier:@"YYRoomYinxiaoCell"];
}
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.dataArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
YYRoomYinxiaoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YYRoomYinxiaoCell" forIndexPath:indexPath];
NSString *str = self.dataArray[indexPath.row];
cell.nameLab.text = str;
cell.imgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"yinxiao_%@", str]];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.onPlayBlock) {
self.onPlayBlock(self.dataArray[indexPath.row]);
}
[self removeFromSuperview];
}
@end