| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | ////  ASCategaryListCell.m//  Asteria////  Created by iOS on 2023/6/6.//#import "ASCategaryListCell.h"#import "ASCategaryCollectCell.h"#import "ASJumpModel.h"@interface ASCategaryListCell () <UICollectionViewDelegate,UICollectionViewDataSource>@property (nonatomic, strong) UICollectionView *collV;@end@implementation ASCategaryListCell- (void)setArr:(NSArray<ASJumpModel *> *)arr {    _arr = arr;    [self.collV reloadData];}- (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}- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];    if (self) {        self.selectionStyle = UITableViewCellSelectionStyleNone;        self.contentView.backgroundColor = UIColor.whiteColor;        [self.contentView addSubview:self.collV];        [self.collV mas_makeConstraints:^(MASConstraintMaker *make) {            make.top.equalTo(self.contentView).offset(30);            make.leading.trailing.equalTo(self.contentView);            make.height.equalTo(@112);            make.bottom.equalTo(self.contentView).offset(-25);        }];    }    return self;}- (UICollectionView *)collV {    if (!_collV) {        UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];        layout.itemSize = CGSizeMake(112, 112);        layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);        layout.minimumLineSpacing = 5;        layout.minimumInteritemSpacing = 5;        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;        UICollectionView *col = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 112) collectionViewLayout:layout];        [col registerClass:[ASCategaryCollectCell class] forCellWithReuseIdentifier:@"ASCategaryCollectCell"];        col.showsHorizontalScrollIndicator = false;        col.delegate = self;        col.dataSource = self;        col.backgroundColor = UIColor.whiteColor;        _collV = col;    }    return _collV;}// MARK: - coll delegate datasource- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {    return _arr.count;}- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {    ASCategaryCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASCategaryCollectCell" forIndexPath:indexPath];    if (self.arr.count <= indexPath.row) {        return cell;    }    ASJumpModel *m = self.arr[indexPath.row];    [cell.imgV sd_setImageWithURL:[NSURL URLWithString:m.image]];    cell.titleLb.text = m.title;    return cell;}- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {    if (self.arr.count <= indexPath.row) {        return ;    }    ASJumpModel *m = self.arr[indexPath.row];    if (self.selectCategory) {        self.selectCategory(m, indexPath);    }}@end
 |