// // JXVipCenterView.m // shiku_im // // Created by 123 on 2020/5/30. // Copyright © 2020 Reese. All rights reserved. // #import "JXVipCenterView.h" #import "JXVipDetailCCell.h" @interface JXVipCenterView() @property (nonatomic,weak) UICollectionView *collectionView; @end @implementation JXVipCenterView //+(instancetype)XIBJXJXVipCenterView{ // // return [[NSBundle mainBundle]loadNibNamed:@"JXVipCenterView" owner:self options:nil].firstObject; //} -(void)setDataArr:(NSMutableArray *)dataArr{ _dataArr=dataArr; [_collectionView reloadData]; } -(instancetype)initWithFrame:(CGRect)frame{ if (self=[super initWithFrame:frame]) { _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 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; } -(void)scrollViewDidScroll:(UIScrollView *)scrollView{ if ([_delegate respondsToSelector:@selector(jxScrollViewDidScroll:)]) { [self.delegate jxScrollViewDidScroll:scrollView]; } } @end