86 lines
3.2 KiB
Objective-C
86 lines
3.2 KiB
Objective-C
//
|
|
// QXIntimateListCell.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/11/20.
|
|
//
|
|
|
|
#import "QXIntimateListCell.h"
|
|
#import "QXIntimateUserCell.h"
|
|
|
|
@interface QXIntimateListCell()<UICollectionViewDataSource,UICollectionViewDelegate>
|
|
@property (nonatomic,strong)UICollectionView *collectionView;
|
|
@end
|
|
|
|
@implementation QXIntimateListCell
|
|
+(instancetype)cellWithTableView:(UITableView *)tableView{
|
|
static NSString *cellId = @"QXIntimateListCell";
|
|
QXIntimateListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
|
|
if (!cell) {
|
|
cell = [[QXIntimateListCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId];
|
|
cell.backgroundColor = [UIColor clearColor];
|
|
}
|
|
return cell;
|
|
}
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
self.backgroundColor = [UIColor clearColor];
|
|
self.contentView.backgroundColor = [UIColor clearColor];
|
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
|
|
-(void)initSubviews{
|
|
NSInteger maxCount = 3;
|
|
NSInteger margin = 14;
|
|
CGFloat btnWith = (int)(SCREEN_WIDTH-48-14*2-1)/maxCount;
|
|
CGFloat btnHeight = ScaleWidth(125);
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
layout.itemSize = CGSizeMake(btnWith, btnHeight);
|
|
layout.minimumLineSpacing = 0;
|
|
layout.minimumInteritemSpacing = 14;
|
|
layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
|
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
|
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
|
[self.collectionView registerNib:[UINib nibWithNibName:@"QXIntimateUserCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXIntimateUserCell"];
|
|
self.collectionView.delegate = self;
|
|
self.collectionView.dataSource = self;
|
|
self.collectionView.showsHorizontalScrollIndicator = NO;
|
|
self.collectionView.bounces = NO;
|
|
self.collectionView.backgroundColor = UIColor.clearColor;
|
|
[self.contentView addSubview:self.collectionView];
|
|
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.bottom.equalTo(self.contentView);
|
|
make.left.mas_equalTo(24);
|
|
make.right.mas_equalTo(-24);
|
|
}];
|
|
}
|
|
-(void)setModel:(QXRoomBestFriendListModel *)model{
|
|
_model = model;
|
|
[self.collectionView reloadData];
|
|
}
|
|
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
|
return self.model.relation_list.count;
|
|
}
|
|
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
QXIntimateUserCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXIntimateUserCell" forIndexPath:indexPath];
|
|
cell.model = self.model.relation_list[indexPath.row];
|
|
return cell;
|
|
}
|
|
- (void)awakeFromNib {
|
|
[super awakeFromNib];
|
|
// Initialization code
|
|
}
|
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
|
[super setSelected:selected animated:animated];
|
|
|
|
// Configure the view for the selected state
|
|
}
|
|
|
|
@end
|