// // JXVipDetailTcell.m // shiku_im // // Created by 123 on 2020/5/16. // Copyright © 2020 Reese. All rights reserved. // #import "JXVipDetailTcell.h" #import "JXVipDetailCCell.h" @interface JXVipDetailTcell() @property (nonatomic,weak) UICollectionView *collectionView; @end @implementation JXVipDetailTcell + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *ID = @"JXVipDetailTcell"; JXVipDetailTcell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (!cell) { cell = [[JXVipDetailTcell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID]; cell.selectionStyle=UITableViewCellSelectionStyleNone; } return cell; } -(void)setDataArr:(NSMutableArray *)dataArr{ _dataArr=dataArr; [_collectionView reloadData]; } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) { _dataArr=[NSMutableArray array]; UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init]; flowLayout.minimumInteritemSpacing = 10; flowLayout.minimumLineSpacing = 10; flowLayout.sectionInset = UIEdgeInsetsMake(15, 60, 5, 15); flowLayout.itemSize = CGSizeMake(JX_SCREEN_WIDTH - 110, 120); flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal; UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 120) collectionViewLayout:flowLayout]; collectionView.delegate = self; collectionView.dataSource = self; collectionView.backgroundColor=[UIColor whiteColor]; self.collectionView=collectionView; [self.contentView addSubview:collectionView]; [collectionView registerNib:[UINib nibWithNibName:@"JXVipDetailCCell" bundle:nil] forCellWithReuseIdentifier:@"JXVipDetailCCell"]; [collectionView reloadData]; } return self; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return _dataArr.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { JXVipDetailCCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"JXVipDetailCCell" forIndexPath:indexPath]; cell.layer.cornerRadius=15; cell.layer.masksToBounds=YES; vipDetailModel *model=_dataArr[indexPath.row]; cell.model=model; return cell; } @end